Layering and Visibility

Layering objects is a powerful way to control specific objects in a complex picture or process. One of the most common uses for layering is when you are developing large displays, and you want your operators to be able to easily distinguish specific parts of the picture. By assigning a layer or multiple layers to objects in the picture, you determine which objects within the picture are visible to the operator. Further, layers are an effective security feature in that you can turn off a specific layer so that certain objects cannot be viewed by one or a set of operators.

You can establish layering using the Set Layer and Display Layers buttons on the Tools toolbar (Classic view) or from the Format tab in the Picture group, in the Layers list (Ribbon view). Setting a layer assigns a layer to a selected object. Displaying layers, on the other hand, applies to the entire picture, and determines what layers are displayed in your picture.

The following illustration shows two objects, Oval1 and Rect1, added to a picture.

 

Next, layers are assigned to the objects as follows:

  1. The object Oval1 is set with a layer of 1.
  2. The object Rect1 is set with a layer of 2.

Then, display layers are set to 1. The following figure shows what is displayed based on the layering that was assigned.

 

Next, the same objects are grouped, and layers are assigned to the objects as follows:

  1. The object Oval1 is set with a layer of 1.
  2. The object Rect1 is set with a layer of 2.
  3. The grouped object Group1 is set with a layer of 1.

Then, display layers are set to 1. The grouped object is displayed, including one of its member objects (the oval).

Layers are controlled by the LayerName property, which can be animated using the Misc tab in the Advanced Animations dialog box, or by writing VBA scripts. In addition to the examples cited above, you can also effectuate the layering function in the run-time environment. After assigning layers to a set of objects, the objects appear at run-time according to the layering you have set.

What appears on your screen, whether you are in the configuration or run-time environments, is determined by the Visible property. However, this is only true if the layer assigned to that object is displayed. For example, if you assign the Visible property for an object to True, but that object does not appear in your picture, it is probably because the object is assigned to a layer that is not displayed (the LayerName property takes precedence over the Visible property).

Using the Visibility Expert

You can also set conditions for the Visible property using the Visibility Expert. This Expert lets you assign a data source to the property, or create an expression using conditional values and relational operators. To use the Visibility Expert, click the Visibility Expert button on the Experts toolbar (Classic view), or access the Visibility Expert from the Tools tab, in the Animations group (Ribbon View). If the Toolbox is enabled, click the button on the Toolbox. For help on the Expert fields, click the Help button on the Expert.

Setting the Layer Property Through VBA

When you set the Layer property through VBA, the layers are related to the property number by a bit mask. In the following equation, n is the layer number that you want to display:

picture.displaylayer = 2n-1

For example, if you want to display layer 3, picture.displaylayer would be equal to 23-1, which is simplified to 22, which is equal to 4. So, you would use the following VBA code:

picture.displaylayer = 4

If you want to display layer 4, picture.displaylayer would be equal to 24-1, which is simplified to 23, which is equal to 8. So, you would use the following VBA code:

picture.displaylayer = 8

See Also

How Do I...