<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) INRIA - Jean-Baptiste Silvy
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 -->
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"  xml:lang="en" xml:id="swap_handles">
    <refnamediv>
        <refname>swap_handles</refname>
        <refpurpose>Permute two handles in the graphic
            Hierarchy.
        </refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>swap_handle( handle1, handle2 )</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>handle1</term>
                <listitem>
                    <para>first handle of the permutation.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>handle2</term>
                <listitem>
                    <para>second handle of the permutation.</para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            The <emphasis role="bold">swap_handles</emphasis> function allows to permute two handles in the
            graphic hierarchy. The first handle will take the second handle position
            and vice versa.
        </para>
        <para>The handles must have the same parent type or the same type to avoid incompatibilities.
        </para>
        <para>This routine may be used on children of the same parent to change their
            indices.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
//-----------------//
//  First example  //
//-----------------//

// create a rectangle
xrect( 0.5, 0.5,0.5,0.5) ;
rect = gce() ;

// create a circle
xarc( 0.5, 0.5, 0.5, 0.5, 0, 64 * 360 ) ;
circle = gce() ;

// create an arrow
xpoly([0,1],[0,1]) ;
arrow = gce() ;
arrow.polyline_style = 4 ;
arrow.arrow_size_factor = 4 ;

// get the list of children
axes = gca()  ;
axes.children

// change the order
swap_handles( rect, arrow ) ;
swap_handles( arrow, circle ) ;

// get the new order
axes.children

//-----------------//
//  Second example //
//-----------------//

// create two windows
plot2d ;
axes1 = gca() ;

scf() ;
fec ;
axes2 = gca() ;

// swap their axes
// note that the color map does not change.
swap_handles( axes1, axes2 ) ;
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="graphics_entities">graphics_entities</link>
            </member>
            <member>
                <link linkend="copy">copy</link>
            </member>
            <member>
                <link linkend="delete">delete</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
