Managers > Basic Manager Features > Manager Layers
 
Manager Layers
Layers are storage places for graphic objects, as shown in Figure 1.3.
Figure 1.3    Layers
Once these objects have been stored they are controlled by and organized under the same manager. Each layer is unique to and can be controlled by only one manager. Each graphic object handled by a manager belongs to one and only one layer.
Note: For more member functions dealing with layers, see the IlvManager and IlvManagerLayer classes.
This section is divided as follows:
*Layer Index
*Layer Selectability
*Layer Visibility
*Layer Rendering
Layer Index
Layers are stored by the manager according to their index. The first layer has index 0 and layer N has index N -1. Layers are represented by an instance of the IlvManagerLayer class, but most of the time they are identified in member function signatures by their index in the manager. Various member functions let you manipulate these layers or the objects that they own.
The manager draws the layers one by one, starting at index 0. Consequently, the top-most layer on the screen is the one with the highest index. This introduces a visual hierarchy among graphic objects based on their layer index. In general, graphic objects of a more static nature—for instance, objects used as background for your Rogue Wave Views programs—are put in a lower layer of the manager. Graphic objects of a dynamic nature—objects with which users interact—are typically put in a higher layer. The top-most layer (the one with the highest index) is reserved for use by the manager; it contains the selection objects displayed as square handles around selected objects. Since the manager increases the index of this layer as new layers are added, it always remains on the top of the stack.
Setting-Up Layers
By default, a manager is created with two layers. You can change this number when creating a manager by using the second parameter of the constructor. You can also change this number once the manager has been created, by using the setNumLayers member function.
Reminder: You must refer to the layers by index numbers starting with 0. For example, layer 3 is indexed as 2.
Example
The following code adds an object to the second layer (specified by index 1) of the manager and then moves the object to layer 0.
manager->addObject(object, IlvTrue, 1);
manager->setLayer(object, 0);
 
When adding a graphic object using a non-existing layer index, the number of layers is increased automatically.
IlvManager* manager = new IlvManager(display); // A manager with 2 layers
IlvRectangle* rect = new IlvRectangle(display, IlvRect(0, 0, 100, 100));
// Add the object in layer 7 and create intermediate layers
manager->addObject(rect, IlFalse, 7);
Layer Selectability
Layer selectability indicates whether the application end-user can select the objects within a certain layer. Preventing your program user from selecting graphic objects in a layer means that these objects are fixed and unchangeable. The following member functions are used for layer selectability:
*setSelectable
*isSelectable
Layer Visibility
Layer visibility indicates whether the objects within a certain layer should be visible to the user. This notion of layer visibility is not as simple as it seems because a layer can be hidden in several different ways:
*Globally - Hidden in all the manager views.
*Locally - Hidden in one or several manager views.
*Contextually - Hidden by an application visibility filter.
A layer is displayed in a view if it is not hidden in any of these ways.
Global Visibility
If a layer is hidden globally, it will not be displayed in any of the manager views. The following IlvManager member functions allow you to get or set the global visibility of a layer:
*setVisible (int layer, IlBoolean val)
*isVisible (int layer)
Local Visibility
Use the following IlvManager member functions to get or set the visibility of a layer for a given manager view:
*setVisible (const IlvView* view, int layer, IlBoolean visible)
*isVisible (const IlvView* view, int layer)
Visibility Filter
IlvLayerVisibilityFilter is an abstract class. Subclasses must redefine the virtual member function isVisible to return the visibility status of the layer.
Each manager layer handles a list of visibility filters. When a layer must be drawn in a view, the manager calls the member function isVisible for all the filters of the layer; if a visibility filter returns IlFalse, the layer is not displayed. This mechanism only allows the application to hide layers that would be otherwise visible; it does not allow you to show hidden layers.
To add a visibility filter to a layer, use IlvManagerLayer::addVisibilityFilter.
Layer Rendering
Layer rendering indicates how the layer is to be rendered onto the drawing device. Two attributes of the layer can change its rendering:
*Alpha Value
*Anti-aliasing Mode
Alpha Value
The alpha value of a layer represents the opacity with which this layer will be drawn above other layers. If the layer contains objects having transparent colors, the transparency of the layer and the transparent objects will be composed.
The default value for this setting is IlvFullIntensity, which means that the layer is completely opaque.
See the IlvManagerLayer::setAlpha method for details.
Anti-aliasing Mode
The anti-aliasing mode of a layer is a global setting that will be applied to all the objects of this layer. It indicates the anti-aliasing mode with which objects are going to be rendered.
The default value for this setting is IlvDefaultAntialiasingMode, which means that the anti-aliasing mode of the layer will be inherited from the drawing port itself. For example, if the anti-aliasing mode of a manager view has been set to IlvUseAntialiasingMode (see IlvPort::setAntialiasingMode), it means that all the layers of this view will use anti-aliasing. You can override this setting for a specific layer by indicating that you do not need anti-aliasing for this layer.
See the IlvManagerLayer::setAntialiasingMode method for details

Version 5.5.1
Copyright © 2012, Rogue Wave Software, Inc. All Rights Reserved.