# Managing Layers

## Introduction to Layers

In Dia, layers are managed through the Layers Dialog and all layers related operations can be achieved from this dialog.

As a general purpose, layers aim at being a shortcut for grouping related objects within a diagram. They allow you to isolate the different parts of a diagram, in the way which you can decide to show only certain parts of it and not some others will stay hidden even when exporting or printing the diagram.

Inside a layer, any operation you would like to perform on objects are possible through the Main Popup Menu, then you can act on objects just the way you use to.

Only objects present in the current layer can be selected. If an object doesn't want to be selected, you should check if it is laying in the current layer or not.

By default, each new diagram comes with the default layer which it's called the Background layer. Of course you can change its name and settings to customize it to your needs as you can do with any other layer.

You can create as many layers as you want, Dia will put a new layer on top of all the layers have been already created. Layers can be thought as a stack of transparent papers. Meaning you will be able to change their stack order, decide whether or not to show them, draw any number of objects onto them and so on.

All this can be manage through the Layers Dialog.

## Managing Layers Basics

### Create a New Layer

Creating a new layer is possible by clicking on the New Layer button at the bottom left of the dialog. Since the Layers Dialog is not diagram specific but application specific, you will have to choose in wich diagram the new layer must go in. To do so, at the top of the Layers Dialog, select the diagram you wanted to receive the new layer and then add this new layer to the selected diagram.

The newly created layer will be placed on top of the stack and will become the current layer of the selected diagram.

Then it's possible to edit any new object of your choice, copy and paste from any other layer or diagram as you could do it in single layer diagram.

### Selecting Layers

A layer is said as being activated when it is selected in the Layers Dialog. To select a layer simply click on its name in the dialog, that will highlight it. From now, any changes you will make to the diagram will affect this layer and only this one.

You'll be able to select only one layer at the time. That way you can do anything you like in this selected layer without affecting other layers on your diagram.

### Ordering Layers

Next to the New Layer button at the bottom of the Layers Dialog, are two useful buttons which allow you to set the stack order of each layer you created.

Those two buttons are used to raise and lower layers in the hierarchy of layers. The button with the up arrow is used to raise the active layer while the other is for lower the position within the hierarchy.

Ordering layers can be useful when you want hide some parts of an object with another one.

### Deleting Layers

When a layer is not needed anymore you can delete it and all the objects it contains by clicking on the Delete Layer button. Of course this will only affect the currently selected layer.

Doing so on regular basis is the better way to keep your diagram clean and light for when you want to export it to another format than the native Dia format.

Note you should be aware of any diagram you created must at least contains one layer, only because a diagram is built of layer, so a diagram doesn't contain any layer should be considered as a corrupted diagram and won't be suitable to export nor even save in the native Dia format.

## Viewing Layers

Now that you've seen what are the basics of manipulating layers, you will more easely understand why layers are such a powerful tool when you are building a diagram with Dia.

Understanding what layers are for can dramaticaly improve the quality and the visual effect your diagrams will produce.

For instance, imagine you are building a diagram with lots of objects in it, like an Electrical or UML diagram, if you drop all of your objects in the same layer, meaning the background, after a while you will get a huge unmanageable draft you won't be able to do anything with it. It will be a pain to change anything in it, you will waste time trying to remenber what object is connected to that object which seems to take all the place in the middle of the mixed up objects you already put there.

Since Dia is a Structured Diagram Builder, all the diagrams you will build with it will be naturaly structured and broken down in many little pieces you will manage with more ease and efficiency than you could do it with a single monolythic block of objects.

By definition, a diagram should be structured, so breaking it down in several logical parts won't be as hard as it seems to be. That's where layers becomes of first use. They allow you to isolate each of these parts in separated slides, so it becomes a real pleasure to manipulate them in any way you like.

First, layers can be renamed to express the part of the diagram they represent, giving them the ability to be rapidely located among others. And most importantly, layers can be shown or hidden depending on what part of the diagram you would like to show.

To rename a layer, at any moment during the construction of the diagram, double-click on the name of the layer in the Layers Dialog. This will bring up the Layer Attributs pop up dialog where you'll be able to change the name of the layer.

Try to find some name which matches the purpose of the layer is a useful way to remember what it is for. Don't hesitate to create many different layers in your diagram, Dia doesn't constrain you on the number of layers you've created, so feel free to adjust your own hierarchy to your needs.

The Eye Icon on the left of the layer's name is what make layers so useful, it aims at hiding or showing the corresponding layer. Meaning if for any reason you decided to not show a particular layer, simply click on the Eye Icon and the layer and everything it contains will disappear from the Canvas.

Viewing only certain layers is really useful when you want manipulate a small part of your diagram without affecting the rest. You can also work that way if you want to print your diagram on different pages or testing different settings which can affect the layout of that part. Again, feel free to experiment with layers, if set up properly they can make your diagram looks pretty much better.

In Dia, Layers creation and manipulation are as common as drawing or selecting objects in the diagram. You must get your hands on them, because you will probably have to use them anytime you will want to creat a new diagram.