Cloning allows parts of the structure of a net to be reused, either elsewhere in the net or in other nets.
Cloning individual elements
Cloning an element of a CPN – for exampole, a place – is designed to be similar in use to the Create tools. Once the element has been cloned, the tool in hand is similar to a create tool, except that the attributes of the created element are the same as those of the one being cloned. In the case of arcs, the shape of the arc is determined when the clone is placed on the page, in the same way as with the Create arc tool.
Inscriptions can also be cloned and result in a cursor with the inscription attached that may be applied to a suitable element. This can be used to easily copy complicated inscriptions — for example, arc inscriptions or code segments – that are needed in several places.
Cloning groups of elements
Cloning of groups of elements is an extension of the basic cloning, where more than one element is cloned at the same time.
If a group is selected, and the target of the clone tool is a member of the selected group, then the elements in the group will be cloned. As with cloning of individual elements, the result is a cursor with the cloned elements attached that may be used to insert them one or more times.
Note that there are some restrictions on what can be cloned in this way. The cloned group of elements must not have any dangling arcs (arcs with one or two endpoints not in the group), attempting to clone a group with dangling arcs result in an error message similar to the one below. Similarly, inscriptions cannot be cloned as part of a group unless the element they are attached to is also in the group.
If a group of elements contains substitution transitions, then new instances of the subpages will be created when the group of elements is cloned; that is, the subpages are not cloned. Cloning subpages is described on the help page for deep cloning.
Clone between nets
Every cloned element can be placed in an arbitrary open net. In this way, cloned elements can be transported across nets. The same goes for groups of elements, meaning, you can clone entire groups of elements to other nets.
Cloning subpages between nets is more complicated. The hierarchical relationships that are created in the new net depend on the way in which new objects are created.
Assume that a group of elements containing a substitution transition has been cloned in one net by applying the Clone element tool to an element in a group. The tool-in-hand is now a clone of a group of elements.
When this tool is applied several times in another net before applying the Drop tool, then several instances of the subpages will be created. As can be seen in the previous example, applying the tool twice in a net (different from the net from which the clone was made) will result in two instances of the page named Subpage (clone)
. These instances are shown below as Subpage (clone) (1)
and Subpage (clone) (2)
.
Another way to clone subpages between nets is to:
- Clone a group of elements including a substitution transition in one net.
- Apply the tool-in-hand – that is, create copies of the original elements – to a page in another net.
- Reset the Clone element tool by applying the Drop tool or by quitting CPN Tools, for instance.
- Repeat steps 1. and 2. using the same nets.
In this case, independent copies of the subpages will be created; that is, new instances of the same subpage will not be created. These independent copies of the subpage will have the same name – for example, Subpage (clone)
– but they will otherwise be unrelated to each other. In the next example, the two pages named Subpage (clone)
are completely independent from each other.
Clone a page
The Clone Element tool also allows cloning of a page or a hierarchy of pages. In this case, a new page is created for each page in the cloned hierarchy (i.e., the page being cloned and all of its subpages), each with the text(clone
appended to its name.
The top page will be cloned, and it will be independent of the original page, but for all subpages, new instances of the original subpages will be created. Once pages have been cloned, it is possible to rearrange them in the hierarchy (as described in hierarchy).
Guidelines, groups, and fusion sets are also cloned to the new page containing the cloned elements of the original page.
Currently it is not possible to clone a page between nets. A workaround to this problem is to create a new page in the other net. Then clone the elements of the page you wish to clone, and place them on the new page in the other net. Because guidelines cannot be part of a group and groups cannot be part of another group, guidelines and groups have to be made by hand. Note that any guideline or group on subpages of the elements cloned to the new page will have their guidelines and groups to the new net.
Clone group
Cloning a group is not the same as cloning the elements of a group. When a group is cloned, a new group is created with (initially) the same members as the original group. Members may then be added to or removed from the new group using the Toggle group tool, as if the group had been created with New group.
Clone fusion set
Cloning a fusion set will simply add a place to the fusion set if it is cloned within the new or the cloned fusion set. If it is cloned to another net, a fusion set is made and the following places the cloned fusion set is applied to will be added to the cloned fusion set.
Related pages
Clone element, Deep cloning, Groups, Adding places, transitions, and arcs, Add/edit inscriptions
You must be logged in to post a comment.