BIOSCILAB
SCILAB 4.0 PAS-A-PAS
SCILAB 4.0 STEP-BY-STEP


Jacques-Deric Rouault

CNRS / INRIA

Volume 4   LE GRAPHISME
Volume 4   GRAPHISM
4.29  LE HANDLE COMPOUND
4.29  THE HANDLE COMPOUND
Version 4.0.29 du 31 Janvier 2006
Version 4.0.29, January 31th 2006
Scilab 4.0 / Windows - Linux

4.24  LE HANDLE LABEL
4.24  THE HANDLE LABEL
ALLER A L'INDEX GENERAL
GO TO THE GENERAL INDEX
ALLER A LA TABLE GENERALE
GO TO THE GENERAL TABLE
4.30  LE HANDLE AGREGATION
4.30  THE HANDLE AGREGATION

4.29.01   Présentation
4.29.01   Presentation
4.29.02   Liste des champs
4.29.02   Fields list

4.29.03   Parent et enfants
4.29.03   Parent and children

4.29.04   Déclaration
4.29.04   Declaring
4.29.10   visible
4.29.20   user_data
4.29.50   Fonction glue
4.29.50   Function glue

4.29.51   Fonction unglue
4.29.51   Function unglue


4.29.01   Présentation
4.29.01   Presentation

Compound

Le Handle Compound code un objet graphique intermédiaire qui permet de regouper sous un handle unique plusieurs objets graphiques.
The handle Compound codes an intermediate graphic object which gathers several graphic objects under a common handle.

Le handle Compound est implémenté dans Scilab à partir de la version 4.0, et remplace le handle Agregation.
The handle Compound is implemented in Scilab from version 4.0, in replacement of handle Agregation..

4.29.02   Liste des champs
4.29.02   Fields list

type (Compound)

Le Handle Compound contient 4+1 champs.
The handle Compound has 4+1 fields.

//  Program Spas42902A
//  Designed for Scilab 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.29.02A");
rect1 = [0.0; 1.0; 1.0; 1.0];
rect2 = [0.1; 0.9; 0.8; 0.8];
rectangles = [];
rectangles (1,1) = rect1 (1);
rectangles (2,1) = rect1 (2);
rectangles (3,1) = rect1 (3);
rectangles (4,1) = rect1 (4);
rectangles (:,2) = rect2 (:);
colors = [];
colors (1) = -2;
colors (2) = -3;
hf = scf (1);
hf.figure_name = "4.29.02A";
ha = gca ();
xrects (rectangles,colors);
hg = gce (),

Télécharger le fichier Spas42902A.sce.
Download the file Spas42902A.sce.







La procédure xrects trace simultanément plusieurs rectangles qui sont regroupés dans  le même handle de type Compound.
The procedure xrects simultaneously raws several rectangles which are grouped in the same handle of type Compound.

Dans la programmation Scilab, un Compound est associé à une variable de type 9 ou handle.
In the Scilab programming, a Compound  is associated to a variable of type 9 or handle.

Le champ Compound.type n'est pas modifiable.
The field Compound.type cannot be modified.

//  Program Spas42902B
//  Designed for Scilab 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.29.02B");
rect1 = [0.0; 1.0; 1.0; 1.0];
rect2 = [0.1; 0.9; 0.8; 0.8];
rectangles = [];
rectangles (1,1) = rect1 (1);
rectangles (2,1) = rect1 (2);
rectangles (3,1) = rect1 (3);
rectangles (4,1) = rect1 (4);
rectangles (:,2) = rect2 (:);
colors = [];
colors (1) = -2;
colors (2) = -3;
hf = scf (1);
ha = gca ();
xrects (rectangles,colors);
hg = gce ();
hg.type,

Télécharger le fichier Spas42902B.sce.
Download the file Spas42902B.sce.



4.29.03   Parent et enfants
4.29.03   Parent and children

parent (Compound)

Le handle Compound a pour handle parent le repère ou système d'axes auquel il est associé.
The handle Compound has for handle parent the system of axes to which it is associated.

Le handle Compound a pour handle parent le repère ou système d'axes auquel il est associé
.
The handle Compound has for handle parent the system of axes to which it is associated.

4.29.04   Déclaration
4.29.04   Declaring

glue (Compound)
parent (Compound)

La déclaration d'un Compound est explicite avec la procédure glue qui retourne son handle.
The declaration of an Compound is explicit with the procedure glue which returns its handle.

//  Program Spas42904A
//  Designed for Scilab 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.29.04A");
hf = scf (1);
hf.figure_name = "4.29.04A";
ha = gca ();
ha.axes_visible = "on";
ha.box = "on";
xrect (0.1, 0.9, 0.8, 0.8);
hr1 = gce ();
xrect (0.2, 0.8, 0.6, 0.6);
hr2 = gce ();
hg = glue ([hr1, hr2]),
delete (hf);

Télécharger le fichier Spas42904A.sce.
Download the file Spas42904A.sce.



La déclaration d'un Compound est implicite : on lance la procédure comme xrects avec plusieurs objets et on récupère son handle.
The declaration of an Compound is implicit: first run a procedure such as  xrects with several objects, then recover its handle.

//  Program Spas42904B
//  Designed for Scilab 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.29.04B");
rect1 = [0.0; 1.0; 1.0; 1.0];
rect2 = [0.1; 0.9; 0.8; 0.8];
rectangles = [];
rectangles (1,1) = rect1 (1);
rectangles (2,1) = rect1 (2);
rectangles (3,1) = rect1 (3);
rectangles (4,1) = rect1 (4);
rectangles (:,2) = rect2 (:);
colors = [];
colors (1) = -2;
colors (2) = -3;
hf = scf (1);
xrects (rectangles,colors);
hg = gce (),
delete (hf);

Télécharger le fichier Spas42904B.sce.
Download the file Spas42904B.sce.



Les procédures legend et legends créent un handle Compound. Voir le chapitre 4.31
The procedures legend and legends create a handle Compound. See the chapter 4.31.

4.29.10   visible

visible (Compound)

Le champ visible du handle Compound controle si les objets qu'il contient sont représentés (valeur "on") ou ne sont pas représentés (valeur "off"). La valeur par défaut est la valeur de Axes.visible, en général "on".
The field visible of the handle Compound controls if the objects coded are represented (value "on") or are not represented (value "off"). The default value is the value of  Axes.visible, usually "on".

//  Program Spas42910A
//  Designed for Scilab 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.29.10A");
rect1 = [0.1; 0.9; 0.8; 0.8];
rect2 = [0.2; 0.8; 0.6; 0.6];
rectangles = [];
rectangles (1,1) = rect1 (1);
rectangles (2,1) = rect1 (2);
rectangles (3,1) = rect1 (3);
rectangles (4,1) = rect1 (4);
rectangles (:,2) = rect2 (:);
colors = [];
colors (1) = -2;
colors (2) = -3;
hf = scf (1);
hf.figure_name = "4.29.10A1";
ha = gca ();
ha.axes_visible = "on";
ha.box = "on";
xrects (rectangles,colors);
hg = gce ();
xpause (5000000);

hf.figure_name = "4.29.10A2";
hg.visible = "off";
xpause (5000000);

hf.figure_name = "4.29.10A3";
hg.visible = "on";
xpause (5000000);
delete (hf);

Télécharger le fichier Spas42910A.sce.
Download the file Spas42910A.sce.



Les deux  rectangles sont affichés, puis le champ visible passe à off et les  rectangles ne sont plus affichés, puis champ visible passe à on et les rectangles sont affichés à nouveau.
The two rectangles are displayed, then the field visible becomes off and the  rectangles are not displayed, then the field visible becomes on and the rectangles are displayed again.

//  Program Spas42910B
//  Designed for Scilab 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.29.10A");
rect1 = [0.1; 0.9; 0.8; 0.8];
rect2 = [0.2; 0.8; 0.6; 0.6];
rectangles = [];
rectangles (1,1) = rect1 (1);
rectangles (2,1) = rect1 (2);
rectangles (3,1) = rect1 (3);
rectangles (4,1) = rect1 (4);
rectangles (:,2) = rect2 (:);
colors = [];
colors (1) = -2;
colors (2) = -3;
hf = scf (1);
hf.figure_name = "4.29.10B1";
ha = gca ();
ha.axes_visible = "on";
ha.box = "on";
ha.visible = "off";
xrects (rectangles,colors);
hg = gce ();
xpause (5000000);

hf.figure_name = "4.29.10B2";
ha.visible = "on";
hg.visible = "on";
xpause (5000000);

hf.figure_name = "4.29.10B3";
hg.children (1).visible = "on";
hg.children (2).visible = "on";
xpause (5000000);
delete (hf);

Télécharger le fichier Spas42910B.sce.
Download the file Spas42910B.sce.

4.29.20   user_data

user_data (Compound)

Le champ user_data du handle Agregation est un vecteur qui contient des variables définies par l'utilisateur. Par défaut, ce champ est vide (valeur []).
The field user_data of the handle Agregation is a vector containing variables defined by the user. By default, this field is empty (value []).

//  Program Spas42920A
//  Designed for Scilab 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.29.20A");
rect1 = [0.1; 0.9; 0.8; 0.8];
rect2 = [0.2; 0.8; 0.6; 0.6];
rectangles = [];
rectangles (1,1) = rect1 (1);
rectangles (2,1) = rect1 (2);
rectangles (3,1) = rect1 (3);
rectangles (4,1) = rect1 (4);
rectangles (:,2) = rect2 (:);
colors = [];
colors (1) = -2;
colors (2) = -3;
hf = scf (1);
ha = gca ();
ha.axes_visible = "on";
ha.box = "on";
xrects (rectangles,colors);
hg = gce ();
hf.figure_name = "4.29.20A1";
xpause (5000000);

hf.figure_name = "4.29.20A2";
hg.user_data = [hg.children(1).foreground, hg.children(2).foreground];
hg.user_data,
hg.children(1).foreground = 4;
hg.children(2).foreground = 5;
xpause (5000000);

hf.figure_name = "4.29.20A3";
hg.children(1).foreground = hg.user_data (1);
hg.children(2).foreground = hg.user_data (2);
xpause (5000000);
delete (hf);

Télécharger le fichier Spas42920A.sce.
Download the file Spas42920A.sce.

Les couleurs des rectangles sont mémorisées dans Compound.user_data, modifiés puis rétablies à partir des valeurs mises en mémoire.
The colors of the rectangles are memorized in Compound.user_data, are modified then restaured from the values stored in memory.



4.29.50   Fonction glue
4.29.50   Function glue

glue (Compound)

La fonction glue regroupe plusieurs objets graphiques de types différents en un objet graphique de type Compound, et retourne son handle.
The function glue groups several graphic objects of different types  into a graphic object of type Compound, and returns its handle.

//  Program Spas42950A
//  Designed for Scilab 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.29.50A");
hf = scf (1);
hf.figure_name = "4.29.50A1";
xrect (0.1, 0.9, 0.8, 0.8);
hr1 = gce ();
xrect (0.2, 0.8, 0.6, 0.6);
hr2 = gce ();
xsegs ([0, 1], [0, 1]);
hs1 = gce ();
hh = [hr1, hr2, hs1],
hg = glue (hh),
xpause (5000000);

hf.figure_name = "4.29.50A2";
hg.visible = "off";

Télécharger le fichier Spas42950A.sce.
Download the file Spas42950A.sce.





On remarquera que l'ordre des enfants du handle Compound est l'ordre inverse des handles dans le vecteur de handles.
We notice that the order of the children of the handle Compound is the reverse order of the handles in the handle vector.

Les deux  rectangles et le segment sont affichés, puis le champ visible du handle Compound passe à off et les objets ne sont plus affichés.
The two rectangles and the segment are displayed, then the field visible of the handle Compound becomes off and the  objects are no more displayed.

Le dernier handle Compound créé devient un enfant du handle Axes.
The last handle Compound created becomes a children of the handle Axes.

//  Program Spas42950B
//  Designed for Scilab 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.29.50BA");
hf = scf (1);
hf.figure_name = "4.29.50B";
ha = gce ();
xrect (0.1, 0.9, 0.8, 0.8);
hr1 = gce ();
xrect (0.2, 0.8, 0.6, 0.6);
hr2 = gce ();
xsegs ([0, 1], [0, 1]);
hs1 = gce ();
xsegs ([0, 1], [1, 0]);
hs2 = gce ();
hh1 = [hr1, hs1];
hg1 = glue (hh1);
hh2 = [hr2, hs2];
hg2 = glue (hh2);
ha.children (1),
ha.children (2),

Télécharger le fichier Spas42950B.sce.
Download the file Spas42950B.sce.



Dans une première étape, le handle Axes a 4 handles enfants : deux Rectangle et deux Segs.
At the first step, the handle Axes has 4 handles children : two Rectangle and two Segs.

Après la création de deux handles Compound avec la fonction glue, le handle Axes n'a plus que deux handles de type Agregation, qui ont chacun deux enfants de type Rectangle pour le premier et de type Segs pour le second.
After the creation of the two handles Compound with the function glue, the handle Axes has only two children of type Compound, each of them with two children of type Rectangle for the first one and of type Segs for the second on.



La conséquence est qu'un handle de type quelconque ne peut pas appartenir à deux Compound.
The consequence is that a handle of any type connot belong to two Compound.

4.29.51   Fonction unglue
4.29.51   Function unglue

unglue (Compound)

La fonction unglue divise un objet graphique de type Compound en ses différents composants et retourne leurs handles respectifs.
The function unglue divides a graphic object of type Compound in several graphic objects into , and returns its handle.

Les handles de type Rectangle, Segs, ... et/ou Compound sont placés dans un vecteur de handles.
The handles of type Rectangle, Segs, ... and/or Compound are put in a vector of handles.

//  Program Spas42951A
//  Designed for Scilab 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.29.51A");
hf = scf (1);
hf.figure_name = "4.29.51A1";
ha = gca ();
xrect (0.1, 0.9, 0.8, 0.8);
hr = gce ();
xrect (0.2, 0.8, 0.6, 0.6);
hs = gce ();
ha.children,
xpause (5000000);

hh = [hr,hs];
hg = glue (hh);
ha.children,
xpause (5000000);

vh = unglue (hg);
ha.children,

Télécharger le fichier Spas42951A.sce.
Download the file Spas42951A.sce.



On commence par construire deux objets graphiques, un Rectangle et un Segs, qui sont associés dans le handle hg1.
The program begins by building two graphic objects, one Rectangle and one Segs, which are associated in the handle hg1.

Dans une première étape, le handle Axes a donc un  handle enfants de type Compound.
At the first step, the handle Axes has one handle children of type Compound.

Après l'appel de la fonction unglue, le handle Axes hérite de deux enfants de type Rectangle pour le premier et de type Segs pour le second.
After calling the function unglue, the handle Axes inherits of two children of type Rectangle for the first one and of type Segs for the second one.

4.24  LE HANDLE LABEL
4.24  THE HANDLE LABEL
ALLER A L'INDEX GENERAL
GO TO THE GENERAL INDEX
ALLER A LA TABLE GENERALE
GO TO THE GENERAL TABLE
4.30  LE HANDLE AGREGATION
4.30  THE HANDLE AGREGATION