NI Home
Cart Cart | Help
Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Currently Being Moderated

Customizing the Gauge Control in LabVIEW

VERSION 3

Created on: May 15, 2009 3:13 PM by SimonH - Last Modified:  May 26, 2009 10:08 AM by SimonH

 


image002.jpg

 

Introduction

Customizing controls in LabVIEW only takes minutes and can make a big impact in the usability and visual appeal of your LabVIEW application.  Common reasons for wanting to use custom controls include:

 

  • Desire to make the front panel resemble real world objects
    • i.e. make a gauge look like a car speedometer
  • Setting your application apart from other LabVIEW applications
    • perhaps you are selling or distributing the application and want it to mirror your company’s style or color scheme
  • Developing professional, end-use software for distribution
  • Creating intuitive, easy-to-use interfaces to maximize user efficiency

 

This tutorial will demonstrate how to customize the gauge control in LabVIEW.  Other controls follow similar steps and the principals learned here will easily translate.

Customizing the Gauge Indicator

This tutorial will use the gauge from the modern palette to demonstrate how to customize a standard LabVIEW control.

 

glossy.png

 

Changing Background Images

  1. Start by adding a gauge to your front panel, then select it and copy it to the clipboard. We will come back to it after creating a new background image to replace the plain white background the gauge currently has.

image005.png

2.       There are numerous elements of the gauge control which we can edit.  The needle is the notable exception (although you can change its color).  There is an advantage to leaving the default frame as it is a vector graphic which scales very nicely.  Scaling effects are most visible around the edge of your control so leaving the default frame while customizing the background image and the center piece is a good compromise between scalability and customizability.  In this example we will replace the background and center piece.

 

image008.jpg

 

 

3.       Now you have your background image created it’s time to switch back to LabVIEW. Right click on your gauge and select Advanced»Customize to bring up the control editor.

 

image046.jpg

 

 

4.       Change to Customize Mode by clicking on the wrench icon on the toolbar

 

image048.jpg

 

5.       Customize mode allows you to move, rescale or replace any of the stock components of a control.  In order to use your new background image, right click on the current dial and select Import from File at Same Size….

 

image050.jpg

 

6.       Browse to select your new background image.

 

image052.jpg

 

 

7.       You background will take the place of the original plain background.

 

image054.jpg

 

 

8.       The center piece of the gauge is also replaceable using the same technique.  For this example right click and select Import from File at Same Size… and use the same background image.  You will end up with something like this:

 

image056.jpg

 

9.     Save your new control by selecting File»Save.

 

 

10.   Now when you close the control editor LabVIEW will prompt you if you want to replace the original control.  Click “Yes”.

 

image060.jpg

 

 

11.   Congratulations you have created a nice looking, reusable gauge.  As we created a large background image and kept the original frame your gauge will rescale nicely up to, and probably a little beyond, the size of the original background image size.

 

image062.jpg

 

12.   This is a quick and easy example of what is possible.  Using the control editor you can create almost any style of gauge you’d like, here are few of my favorites:

 

image002.jpg

 

 

13.   In addition to using custom created graphics, using real-life images such as photographs can lend provide a familiar interface to users who are not familiar with virtual instruments.  In this last sample you can see how a photo can be used as the basis of a custom control:

 

image065.jpg

image067.jpg

 

 

 

Other Customizable Elements

The Needle

Properties - Needle.png

 

You can add additional needles to your gauge or change the color of existing needles by right clicking on the gauge and selecting Properties and then the “Appearance” tab.

The Ramp

Customized Ramp.png

 

The ramp has a number of customizable factors.  First of all is whether or not it is displayed at all – you can enable it from the “Scale” tab of the Properties dialog.  The other visual option you have here is “Interpolate Color”.  This option gives you a constant gradient between colors as opposed to blocks of solid color


Changing the color of your ramp is done with the same color tool you can use for just about any front panel element in LabVIEW.  You can bring up the tools palette by holding Shift and right clicking on the front panel.  This works in both interpolated and non-interpolated mode.  Even if you intend for your finished product to be interpolated it may be easier to turn it off while you pick colors and then let LabVIEW interpolate once you are done.

 

 

 

 

You can also adjust the radius and thickness of the ramp by clicking and dragging the handles located at the 12:00 position.

 

 

Scale Ramp.png

 

Finally you can adjust the starting point for your gauge by hovering over a tick mark until your cursor changes (as shown below) and then rotating the entire scale around.

 

Customized Ramp - StartPospng.png

 

 

The More We Share the Easier It Will Get

I strongly encourage anyone who is creating custom controls to share them with the community if your situation allows.  Any customizations can be saved and distributed very easily by simply saving your custom control and uploading the .ctl file to this community group.  As the group grows and more controls are posted you might be able to just download the design you want rather than creating it from scratch as shown here.  You can find all the controls I showed in this tutorial in the attached zip file.

Downloads:
Average User Rating
(7 ratings)




Evan Robinson Evan Robinson  says:

Who's got the Canadian vehicle??

Elijah Kerry Elijah Kerry  says in response to Evan Robinson:

Well, Simon is a Brit.  Makes for a good excuse if you get caught speeding... "I don't know what 30 mph is!"

 

Great job Simon, by the way.

SimonH SimonH  says in response to Elijah Kerry:

Actually Britain still uses mph.  It would be too expensive to change all the road signs to km.

Esley Esley  says:

First of all, I want to say thank you very much. I am now looking for a guideline to make my front panel resemble real automobile dashboard. And your help is available. I just a temporary labVIEW learner, so I really like to see your example file, but I only have LabVIEW 8.5. Do you mind saving as file for 8.5 or older verson. If you wouldn't upload on this site, just send to my e-mail address: Esley.Ng@gmail.com.

 

And I want let you know that your name will be appear in my project (gratitude page) like a contributor. Your tutorial is the key I need to finish my work.

More Like This

  • Retrieving data ...