Products & Services Solutions Academia Support User Community Company

Learn more about Gauges Blockset   

Modifying Properties of a Control

Overview

You can modify many properties of a preconfigured Gauges Blockset block using its ActiveX Control Properties dialog box, introduced in Accessing the Properties. This section discusses some of the more complicated tasks and concepts associated with the modification of properties.

For more information about individual properties of the preconfigured blocks, see the online help for the corresponding controls. To access such help, open the library window and double-click the question-mark block. The online help summarizes the functionality and contains links to information about properties, events, and methods.

Using Multiple Styles Within One Block

Some control properties let you use more than one style for a given component or characteristic, in the same block. For example, you might use multiple styles to create

These sections discuss the use of multiple styles in preconfigured Gauges Blockset blocks:

Blocks That Use Multiple Styles by Default

Many Gauges Blockset blocks include multiple styles by default:

Determining When Multiple Styles Are Allowed

If a component supports multiple styles, then its property dialog box has properties that enable you to set the number of styles and refer to the styles by number. As an example, the figure below shows how a dialog box supports multiple font styles. The Fonts property indicates the number of font styles, while the FontID property refers to a given style by number.

To determine whether a component supports multiple styles, look in the block's property dialog box for a pair of properties whose names are

If the dialog box has no such properties for the component, then you cannot create multiple styles for that component. For example, in the Background panel of a block's dialog box, you can define the color of an outline, but you cannot create multiple concentric outlines of different colors.

Creating Styles

After locating the style-identifying pair of properties for the component you are interested in, follow these steps to create an additional style:

  1. Click once on the up arrow next to the value of the first property in the pair (Fonts in the figure). This value is the number of defined styles. If N styles are defined, then each is associated with an integer between 0 and N–1. The corresponding ID property (FontID in the figure) can assume values between 0 and N–1.

  2. Click repeatedly on the up arrow next to the ID property to set it to its maximum value. This causes the dialog box panel to reflect the attributes of that particular style instead of the other defined styles.

  3. Configure other properties in the dialog box panel to match the attributes that you want that particular style to have. In the figure, the Set Font button enables you to set font attributes and the Sample box displays text using those attributes. In many cases, all properties in the panel except the original style-identifying pair are attributes of the style. In a few cases, only part of the panel contains attributes of the style and others are global attributes that apply to all styles.

To view attributes of an existing style, set the ID property to the integer associated with that style. Then, properties on the dialog box panel other than the style-identifying pair reflect attributes of that style. For example, the following figures show how the Sample portion of the Fonts panel of a dialog box displays either a large bold font or a font of medium size and weight, depending on whether the FontID value is set to 0 or 1.

Applying Styles

In some cases, creating a style implicitly causes the block to apply it. For example, creating an additional style for tick marks automatically creates an additional set of tick marks on the block. In other cases, creating a style does not implicitly cause the block to apply it. For example, even after you create an additional font style, you will not see its effect on the block until you indicate which text should use that style. This section describes how to apply styles that the block does not apply immediately after you create them.

To determine where you can apply a style you have created, look for the corresponding ID property on a panel of the dialog box other than the panel where you defined the style. For example, the figure below shows part of a Captions panel containing the FontID property. The fact that the FontID property is not preceded by a Fonts property indicates that this is a panel that enables you to apply font styles but not define them.

Once you have located a part of the dialog box where you can apply a style you previously created, set the ID property to match the ID property of that style. For example, the figure above shows that the block has exactly one caption, and that the caption's font style is the one whose ID is 1. If you change the FontID value in the Captions panel to a different number, then you will probably notice a change in some text on the block.

Understanding ID Properties

Many blocks have properties whose names end with ID, such as FontID, ScaleID, and NeedleID. Such properties enable you to use more than one style in the same block, as in the situations listed in Using Multiple Styles Within One Block. This section describes how to interpret ID property settings. For an example that examines ID property settings among a block's default settings, see Modifying Multiple Tick Marks.

The value of an ID property refers to a style by number. To determine the purpose of the ID property, first see whether the property directly above it is a plural noun similar to the ID property's name. (For example, see whether the property directly above FontID is Fonts.) Then,

Sometimes, multiple styles are combined so seamlessly that it is not obvious why multiple styles are needed or which parts of the block correspond to which style definitions. You can often adjust the definition of the style to make the style usage more apparent. For example, if you change the colors of different annular regions and then look for the corresponding change in the block, then you should be able to determine how the design is split among multiple annular regions.

Displaying Text on a Block

Many blocks enable you to include text on the block. Such text might describe the quantity being measured, the units of measurement, or other information. The table below lists some types of text that are associated with a specific part of the block, as well as the part of the ActiveX Control Properties dialog box panel that defines the text. Some types of text apply only to certain blocks.

Type of TextPart of Dialog Box That Defines or Enables Text
Title appearing in block's outlineTitle property on Background panel
Numerical labels near tick marksLabels area on Ticks panel. On Strip Chart block, Labels properties on Tracks and X Axis panels.
Numerical labels near pointer or needleDigital panel
Captions appearing anywhere on blockCaptions panel

Using the Captions Panel to Display Text

When it is present, the Captions panel of the ActiveX Control Properties dialog box enables you to place text anywhere on the block. Blocks that use text captions by default include Mixer Scale, Tank, Thermometer, Amp Meter, and Volume. This section describes how to add, remove, and change characteristics of text captions using the Captions panel.

Adding Text Captions.   To create a new text caption, follow these steps:

  1. Increase the value of the Captions property by one.

  2. Set CaptionID to its maximum value. This is the index that corresponds to the newest text caption.

  3. Type the desired text in the Caption edit field.

Removing Text Captions.   To remove the most recently added text caption (that is, the one with the largest CaptionID value), decrease the value of the Captions property by one. Note that this removes all characteristics of that text caption.

Changing Fonts and Other Characteristics of Text Captions.   To change the font of an existing text caption, you must create a numbered font style and then apply that style to the caption. Follow these steps:

  1. Open the Fonts panel of the dialog box.

  2. Allocate space for a new font style by increasing the value of the Fonts property by one.

  3. Set FontID to its maximum value. This is the index that corresponds to the newest font style.

  4. Use the Set Font button to select font characteristics.

  5. Open the Captions panel of the dialog box.

  6. Set CaptionID to the index that corresponds to the text caption whose font you want to change.

  7. Apply the font style to the caption by setting FontID to the font style's index.

To change other characteristics of an existing text caption, first set the CaptionID property on the Captions panel to the value that corresponds to the text caption you want to change. Then use other properties on the dialog box panel, except the Captions counter, to configure the text caption accordingly.

Modifying the Displayed Range

Changing the range of values displayed on a block involves adjusting these properties:

To illustrate how to use these properties to adjust the range of values displayed on a block, this example changes the Generic Linear Gauge to display values from -20 to 20, sets the interval between tick marks to 5, and shows the tick-mark labels. This figure shows the Generic Linear Gauge with its default settings (left) and with modified settings (right).

Changing the Scale

Click the Scales tab to display the scales properties page. This figure shows the default scale properties for the Generic Linear Gauge.

To modify the scale range, change ScaleMax to 20 and ScaleMin to -20.

Displaying Labels Next to Tick Marks

Click the Ticks tab to display the tick-mark properties page. This figure shows the default tick-mark properties.

To show tick-mark labels, check the Label On/Off check box.

To set the starting and ending tick marks so they mark the minimum and maximum scale settings, set StartValue to -20 and StopValue to 20. Change the DeltaValue property, which sets the spacing between tick marks. A value of 5 is reasonable for default block size.

Setting the Current Pointer Value

Click the Pointers tab to display the pointer properties page. This figure shows the default pointer properties.

The Value property indicates the current pointer value. Set the initial value to 0, halfway between the maximum and minimum scale values. Click OK to accept the changes and close the dialog box.

Modifying Multiple Tick Marks

This example illustrates the use of multiple tick marks and the use of the ID property to manage them. Instead of modifying a block, this example examines the default settings for a particular block.

This figure shows the Amp Meter block. Notice that the tick marks have two different lengths. These are created by defining two sets of tick marks.

The first set consists of 11 longer tick marks, each positioned at one of the label values, positioned at increments of 1.0. The second set consists of five shorter tick marks for each integer change in the scale, positioned at increments of 0.2.

To examine how these tick marks have been created, double-click the Amp Meter block to display its properties dialog box. Select the Ticks tab.

The Ticks and TickID properties, in the box labeled 1, are defined as follows:

The Position/Size properties, in the box labeled 2, are defined as follows:

The Range properties, in the box labeled 3, are defined as follows:

The Labels properties On/Off check box, in the box labeled 4, determines whether the labels are displayed. For the first set of tick marks, the labels are displayed.

The FontID property, in the box labeled 5, determines which of multiple fonts defined for this block is used for the label. In this case, two font sets are defined. The first (FontID 0) is for the tick marks, while the second (FontID 1) is for the caption, "Amps."

To examine the second set of tick marks, change the TickID property value to 1 by clicking the up arrow to the left of the value. The Ticks page looks like this.

The Position/Size properties, in the box labeled 2, are defined as follows:

The Range properties, in the box labeled 3, are defined as follows.

The Labels properties On/Off check box determines whether labels appear next to the tick marks. No labels appear next to this set of tick marks.

If you decrease the Ticks property, then the tick-mark settings corresponding to the highest TickID value is removed. To replace that set of tick marks, you will have to recreate the settings from the defaults.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS