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.30 LE HANDLE AGREGATION
4.30
THE HANDLE AGREGATION

Version 4.0.29 du 31 Janvier 2006 / Version 4.0.29, January 31th 2006
Scilab 3.1 - Scilab 4.0 /  Windows - Linux

4.29       LE HANDLE COMPOUND / THE HANDLE COMPOUND
ALLER A L'INDEX GENERAL / GO TO THE GENERAL INDEX
ALLER A LA TABLE GENERALE / GO TO THE GENERAL TABLE
4.31       LE HANDLE LEGEND / THE HANDLE LEGEND

4.30.01   Présentation  / Presentation
4.30.02   Liste des champs  / Fields list
4.30.03   Parent et enfants  / Parent and children
4.30.04   Déclaration  / Declaring
4.30.10   visible
4.30.20   user_data
4.30.50   Function glue
4.30.51   Function unglue

4.30.01   Présentation  / Presentation

Agregation

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

A partir de la version 4.0, le handle Agregation est remplacé par le handle Compound Voir le chapitre 4.29.
From version 4.0, the handle Agregation is replaced by handle Compound. see chapter 4.29.

4.30.02   Liste des champs  / Fields list

Le handle Agregation contient 3 champs.
The handle Agregation has 3 fields.

//  Program Spas43002A
//  Designed for Scilab 3.1
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.30.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.30.02A";
ha = gca ();
xrects (rectangles,colors);
hg = gce (),

Télécharger le fichier / Download the file Spas43002A.sce





4.30.03   Parent et enfants  / Parent and children

Le handle Agregation a pour handle parent un handle Axes ou Agregation.
The handle Agregation has for handle parent a handle Axes or Agregation.

Le handle Agregation a au moins deux enfants, de type Agregation Rectangle, ... .
The handle Rectangle has at least two children, with type Agregation, Rectangle, ... ..

Les enfants du handle Agregation sont accessibles par leur rangs.

The children of handle Agregation are accessible by their ranks.

//  Program Spas43003A
//  Designed for Scilab 3.1
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.30.03A");
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.30.03A";
ha = gca ();
xrects (rectangles,colors);
hg = gce ();
hr1 = hg.children (1),
hr2 = hg.children (2),

Télécharger le fichier / Download the file Spas43003A.sce

NB : l'ordre des enfants du handle Agregation est l'ordre inverse de celui des déclarations.
NOTE: the order of the children of handle Agregation is the reverse order of those of declarations.

//  Program Spas43003B
//  Designed for Scilab 3.1
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.30.03B");
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.30.03B1";
ha = hf.children;
xrects (rectangles,colors);
hg = gce ();
hr1 = hg.children (1),
hr2 = hg.children (2),
xpause (5000000);

hf.figure_name = "4.30.03B2";
hg.children (1).visible = "on";
hg.children (2).visible = "off";
xpause (5000000);

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

Télécharger le fichier / Download the file Spas43003B.sce

4.30.04   Déclaration  / Declaring

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

//  Program Spas43004A
//  Designed for Scilab 3.1
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.30.04A");
hf = scf (1);
hf.figure_name = "4.30.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]),

Télécharger le fichier / Download the file Spas43004A.sce



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

//  Program Spas43004B
//  Designed for Scilab 3.1
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.30.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 (),

Télécharger le fichier / Download the file Spas43004B.sce

On peut aussi récupérer le handle du Rectangle comme enfant du handle Axes.
It is also possible to recover the handle of a Rectangle as the children of handle Axes.

//  Program Spas43004C
//  Designed for Scilab 3.1
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.30.04C");
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 = hf.children;
xrects (rectangles,colors);
hg = ha.children,

Télécharger le fichier / Download the file Spas43004C.sce

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

4.30.10   visible

visible (Agregation)

Le champ visible du handle Agregation 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 Agregation 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 Spas43010A
//  Designed for Scilab 3.1
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.30.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.30.10A1";
ha = hf.children;
ha.axes_visible = "on";
ha.box = "on";
xrects (rectangles,colors);
hg = gce ();
xpause (5000000);

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

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

Télécharger le fichier / Download the file Spas43010A.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  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 Spas43010B
//  Designed for Scilab 3.1
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.30.10B");
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.30.10B1";
ha = gca ();
ha.axes_visible = "on";
ha.box = "on";
ha.visible = "off";
xrects (rectangles,colors);
hg = gce ();
xpause (5000000);

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

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

Télécharger le fichier / Download the file Spas43010B.sce

4.30.50   Function glue

glue (Agregation)

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

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

//  Program Spas43050A
//  Designed for Scilab 3.1
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.30.50A");
hf = scf (1);
hf.figure_name = "4.30.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.30.50A2";
hg.visible = "off";
xpause (5000000);
delete (hf);

Télécharger le fichier / Download the file Spas43050A.sce





On remarquera que l'ordre des enfants du handle Agregation est l'ordre inverse des handles dans le vecteur de handles.
We notice that the order of the children of the handle Agregation 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 Agregation 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 Agregation becomes off and the  objects are no more displayed.

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

//  Program Spas43050B
//  Designed for Scilab 3.1
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.30.50B");
hf = scf (1);
hf.figure_name = "4.30.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),
xpause (5000000);
delete (hf);

Télécharger le fichier / Download the file Spas43050B.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 hendles children : two Rectangle and two Segs.

Après la création de deux handles Agregation 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 Agregation with the function glue, the handle Axes has only two children of type Agregation, each of them with two children of type Rectangle for the first one and of type Segs for the second one.





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

4.30.51   Function unglue

unglue (Agregation)

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

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

//  Program Spas43051A
//  Designed for Scilab 3.1
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.30.51A");
hf = scf (1);
hf.figure_name = "4.30.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,
xpause (5000000);
delete (hf);

Télécharger le fichier / Download the file Spas43051A.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 Agregation.
At the first step, the handle Axes has one handle children of type Agregation.

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 to 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.29       LE HANDLE COMPOUND / THE HANDLE COMPOUND
ALLER A L'INDEX GENERAL / GO TO THE GENERAL INDEX
ALLER A LA TABLE GENERALE / GO TO THE GENERAL TABLE
4.31       LE HANDLE LEGEND / THE HANDLE LEGEND