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.16  CONTROLE DE L'AFFICHAGE
4.16 
CONTROLING DISPLAY

Version 4.0.22 du 6 Janvier 2006 / Version 4.0.22, January 6th 2006
Scilab 3.1 - Scilab 4.0 /  Windows - Linux

4.15       INITIALISATION  / INITIALIZATION
ALLER A L'INDEX GENERAL / GO TO THE GENERAL INDEX
ALLER A LA TABLE GENERALE / GO TO THE GENERAL TABLE
4.17       LA SOURIS GRAPHIQUE  / THE GRAPHIC MOUSE

4.16.01   Introduction  / Introduction
4.16.02   Couches d'affichage  / Display layers
4.16.03   Suspendre l'affichage  / Suspending the display
4.16.04   Controle temporel  / Temporal control
4.16.05   Animations  / Animations
4.16.06   Clignotement  / Flashing
4.16.07   Recadrage  / Reframing
4.16.08   Redessiner  / Redraw
4.16.09   Nettoyer une zone  / Cleanning an area
4.16.50   La zone de rognage  / Area of clipping
4.16.51   Procedure xclip
4.16.52   xget ("clipping")  xset ("clipping")

4.16.01   Introduction  / Introduction

La figure affichée dans la fenetre graphique est le résultat d'un processus complexe, à la fois dans l'espace et dans le temps.
The figure displayed in the graphic window is the result of a complex process, at the same time in space and in time.

Dans ce chapitre, nous indiquons quelques outils propres à controler et optimiser ce processus.
In this chapter, we propose some tools able to control and optimize this process .

4.16.02   Couches d'affichage  / Display layers

Superposing graphic layers
Superposition des couches graphiques


La figure affichée dans la fenetre graphique est le résultat de la superposition de plusieurs couches graphiques.
The figure displayed in the graphic window is the result of the superposition of several graphic layers.

Le système commence d'abord par afficher la fenetre graphique, puis le repère, puis les figures. A la différence de l'ancien mode graphqiue, c'est l'ordre de déclaration qui est pris en compte, et non l'ordre de modification.
The system begins by displaying the graphic window, then the system of axes, then the figures. At the difference of the old graphic mode, the reference order is the declaration order, not the modification order.

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

disp ("4.16.02A");
hf = scf (1);
hf.figure_name = "4.16.02A1";
hf.background = 2;  // bleu blue
xclick;

hf.figure_name = "4.16.02A2";
ha= gca ();
ha.axes_visible="on";
ha.background = 3; // vert green
xclick;

hf.figure_name = "4.16.02A3";
xfrect (0.2, 0.8, 0.6, 0.6);
hr1 = get ("hdl");
hr1.background = 4;  // cyan
xclick;

hf.figure_name = "4.16.02A4";
xfrect (0.4, 0.6, 0.2, 0.2);
hr2 = get ("hdl");
hr2.background = 5;  // rouge red
xclick;

hf.figure_name = "4.16.02A5";
hr1.background = 6;  // magenta
xclick;

delete (hf);


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

Il y a d'abord affichage de la fenetre graphique avec un fond bleu. Cliquer la souris dans la fenetre graphique.
There is first the display of the graphic window, with a blue background. Click the mouse in the graphic window.



Il y a ensuite affichage du repère avec un fond vert. Cliquer la souris dans la fenetre graphique.
Then, there is  the display of the system of axes, with a gteen background. Click the mouse in the graphic window.



Il y a ensuite affichage du premier rectangle cyan. Cliquer la souris dans la fenetre graphique.
Then, there is  the display of the first rectangle, with the color cyan. Click the mouse in the graphic window.



Il y a ensuite affichage du second rectangle rouge. Cliquer la souris dans la fenetre graphique.
Then, there is  the display of the second rectangle, with the color red. Click the mouse in the graphic window.



Il y a ensuite reaffichage du premier rectangle, avec la couleur magenta à la place du cyan. Fermer la fenetre graphique.
Then, there is  the display of the first rectangle, with the color magenta instead of cyan. Close  the graphic window.



On constate que le second rectangle de couleur rouge n'a pas été masqué par la nouvelle couleur du premier rectangle.
It can be observed that the color of the second red rectangle is not hiden by the new color of the first rectangle..

4.16.03   Suspendre l'affichage  / Suspending the display

drawlater
drawnow

immediate_drawing (Figure, drawlater, drawnow)

A chaque nouvelle instruction, le graphisme est réinterprété et réaffiché, ce qui peut entrainer une saturation du processeur, donc un sérieux ralentissement de l'exécution..
For each new instruction, the graphism is reinterpreted and displayed again, thus causing a saturation of the processor, then a very lower speed of execution.

La procédure drawlater interrompt le processus de reaffichage, qui est repris lorsque la procédure drawnow est exécutée.
The procedure drawlater interrupts the proccess of displaying again, which is resumed when the procedure drawnow is run.

Cliquer la souris dans la fenetre graphique.
Click the mouse in the graphic window.

//  Program Spas41603A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.16.03A");
hf = scf (1);
drawlater;
hf.figure_name = "4.16.03A1";
hf.background = 2;  // bleu blue
ha = gca ();
ha.axes_visible="on";
ha.background = 3; // vert green
xfrect (0.2, 0.8, 0.6, 0.6);
hr1 = get ("hdl");
hr1.background = 4;  // cyan
xfrect (0.4, 0.6, 0.2, 0.2);
hr2 = get ("hdl");
hr2.background = 5;  // rouge red
hr1.background = 6;  // magenta
hr1.visible,
xclick;

drawnow;
hf.figure_name = "4.16.03A2";
xclick;
delete (hf);

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





Ces procédures agissent sur le champ Figure.immediate_drawing (Figure.visible pour la version 3.0).
These procedures acts on the field Figure.immediate_drawing (Figure.visible for the version 3.0).
4.21.19   immediate_drawing

//  Program Spas41603A
//  Designed for Scilab 3.1 & 4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.16.03B");
hf = scf (1);
drawlater;
hf.figure_name = "4.16.03B";
ha = hf.children;
xfrect (0.2, 0.8, 0.6, 0.6);
hr = gce ();
hf.immediate_drawing,
drawnow;
hf.immediate_drawing,
delete (hf);

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



4.16.04   Controle temporel  / Temporal control

xclick
xpause


La procedure xpause interrompt l'exécution du programme durant le délai  exprimé en microsecondes.
The procedure xpause interrupts the running of the program during the delay expressed in microseconds.

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

disp ("4.16.04A");
hf = scf (1);
hf.figure_name = "4.16.04A1";
hf.background = 2;  // bleu blue
ha = gca ();
ha.axes_visible="on";
ha.background = 3; // vert green
xpause (2000000);

xfrect (0.2, 0.8, 0.6, 0.6);
hr1 = get ("hdl");
hr1.background = 4;  // cyan
hf.figure_name = "4.16.04A2";
xpause (2000000);

xfrect (0.4, 0.6, 0.2, 0.2);
hr2 = get ("hdl");
hr2.background = 5;  // rouge red
hf.figure_name = "4.16.04A3";
xpause (2000000);

hr1.background = 6;  // magenta
hf.figure_name = "4.16.04A4";

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

La procedure xclick interrompt l'exécution du programme jusqu'à ce que l'utilisateur clique avec la souris dans la fenetre graphique ou frappe une touche du clavier (si la fenetre est active).
The procedure xclick interrupts the running of the program until the user clicks with the mouse in the graphic window, or strike a key of the keyboard (if the window is active).

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

disp ("4.16.04B");
hf = scf (1);
hf.figure_name = "4.16.04B1";
hf.background = 2;  // bleu blue
ha = gca ();
ha.axes_visible="on";
ha.background = 3; // vert green
xclick;

xfrect (0.2, 0.8, 0.6, 0.6);
hr1 = get ("hdl");
hr1.background = 4;  // cyan
hf.figure_name = "4.16.04B2";
xclick;

xfrect (0.4, 0.6, 0.2, 0.2);
hr2 = get ("hdl");
hr2.background = 5;  // rouge red
hf.figure_name = "4.16.04B3";
xclick;

hr1.background = 6;  // magenta
hf.figure_name = "4.16.04B4";

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

4.16.05   Animations  / Animations

clear_pixmap
show_pixmap


La procédure show_pixmap permet d'afficher des animations beaucoup plus lissées que l'affichage normal.
The procedure show_pixmap displays animations much more smoothly than standard display.

//  Program Spas41605A
//  Designed for Scilab 3.1 &  4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.16.05A");
hf = scf (1);
hf.figure_name = "4.16.05A";
ha = gca ();
ha.data_bounds=[0 0; 10 10];
xrects([0;10;1;1],5);
r1=gce ();
xrects([0;1;1;1],13);
r2=gce ();
for k=1:1000
  move(r1,[0.01,-0.01]);
  move(r2,[0.01,0.01])
end
delete (hf);

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

//  Program Spas41605B
//  Designed for Scilab 3.1 &  4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.16.05B");
hf = scf (1);
hf.figure_name = "4.16.05A";
hf.pixmap='on';
ha = gca ();
ha.data_bounds=[0 0; 10 10];
xrects([0;10;1;1],5);
r1=gce ();
  xrects([0;1;1;1],13);
r2=gce ();
for k=1:1000
  move(r1,[0.01,-0.01]);
  move(r2,[0.01,0.01])
  show_pixmap();
end;
delete (hf);

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

La procédure show_pixmap agit sur le champ Figure.pixmap. Voir 4.21.20   pixmap
The procedure show_pixmap acts on the field Figure.pixmap. See 4.21.20   pixmap

4.16.06   Clignotement  / Flashing

twinkle

La procédure twinkle permet de faire clignoter un objet graphique. Par défaut, le graphique désigné clignote 5 fois.
The procedure twinkle flashes a graphic object. By default, the designed graphic flashes 5 times.

//  Program Spas41606A
//  Designed for Scilab 3.1 &  4.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.16.06A");
hf = scf (1);
hf.figure_name = "4.16.06A";
ha = gca ();
ha.axes_visible="on";
ha.foreground = 5;
xfrect (0, 1, 1, 1);
hr = gce ();
twinkle (hf);
twinkle (ha);
twinkle (hr, 20);

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



4.16.07   Recadrage  / Reframing

replot

La procédure replot redéfinit les limites de la fenetre du tracé graphique.
The procedure replot redefines the limits of the window of graphic drawing.

On donne les nouvelles limites sous la forme [xinf, yinf, xsup, ysup].
The new limits are presented under the form [xinf, yinf, xsup, ysup].

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

disp ("4.16.07A");
hf = scf (1);
hf.figure_name = "4.16.07A1";
ha = gca ();
ha.axes_visible="on";
xfrect (0, 1, 1, 1);
hr = gce ();
hr.background = 5;
xpause (5000000);
hf.figure_name = "4.16.07A2";
replot ([-1, -1, 2, 2]);


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

Avec Scilab 3.1.1, provoque l'erreur 999 (BUG 1449). Bug corrigé avec Scilab.4.0. 
With Scilab 3.1.1, causes the error 999 (BUG 1449). Bug corrected with Scilab.4.0. 





4.16.08   Redessiner  / Redraw

xbasr

La procédure xbasr redessine la fenetre graphique. Ancien graphisme, en voie d'obsolescence.
The procedure xbasr redraws the graphic window. Old graphism, becoming obsolete.

//  Program Spas41608A
//  Designed for Scilab 3.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.16.08A");
hf = scf (1);
hf.figure_name = "4.16.08A1";
ha = gca ();
ha.axes_visible="on";
ha.background = 2;
xfrect (0, 1, 1, 1);
ha.foreground = 3;
xfrect (0.1, 0.9, 0.8, 0.8);
ha.foreground = 4;
xfrect (0.2, 0.8, 0.6, 0.6);
ha.foreground = 5;
xfrect (0.3, 0.7, 0.4, 0.4);
xpause (5000000);
hf.figure_name = "4.16.08A2";
xbasr;

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



4.16.09   Nettoyer une zone  / Cleanning an area

xclea

La procédure xclea nettoie une zone rectangulaire (xinf, ysup, largeur, hauteur) de la fenetre graphique. Ancien graphisme, en voie d'obsolescence.
The procedure xclea  cleans a rectangular area (xinf, ysup, widtht, height) of  the graphic window. Old graphism, becoming obsolete.

//  Program Spas41609A
//  Designed for Scilab 3.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.16.09A");
hf = scf (1);
hf.figure_name = "4.16.09A1";
ha = gca ();
ha.axes_visible="on";
ha.foreground = 5;
xfrect (0, 1, 1, 1);
hr = gce ();
xpause (5000000);
hf.figure_name = "4.16.09A2";
xclea ([-0.1, 0.8, 0.6, 0.9]);

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





La zone nettoyée peut être utilisée à nouveau.
The area cleaned can be used again..

//  Program Spas41609B
//  Designed for Scilab 3.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.16.09B");
hf = scf (1);
hf.figure_name = "4.16.09B1";
ha = gca ();
ha.axes_visible="on";
ha.foreground = 5;
xfrect (0, 1, 1, 1);
xpause (5000000);
hf.figure_name = "4.16.09B2";
xclea ([-0.1, 0.8, 0.6, 0.9]);
xpause (5000000);
hf.figure_name = "4.16.09B3";
xfrect (0, 0.4, 0.4, 0.4);

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



Cependant, avec le nouveau graphisme, le nettoyage d'une zone avec xclea présente un caractère temporaire et aléatoire. Par exemple, toute modification de la fenetre graphique et/ou du système d'axes provoquant un réaffichage complet est de nature à l'inhiber.
However, with the new graphism, cleanindg an area with xclea presents a temporary and random character. For instance, any modification of the graphic window and/or of the system of axes causing a whole image display inhibits this function.

//  Program Spas41609C
//  Designed for Scilab 3.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.16.09C");
hf = scf (1);
hf.figure_name = "4.16.09C1";
ha = gca ();
ha.axes_visible="on";
ha.foreground = 5;
xfrect (0, 1, 1, 1);
xpause (5000000);
hf.figure_name = "4.16.09C2";
xclea ([0.2, 0.8, 0.6, 0.6]);
xpause (5000000);
hf.figure_name = "4.16.09C3";
xfrect (0.3, 0.7, 0.4, 0.4);

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

//  Program Spas41609D
//  Designed for Scilab 3.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.16.09D");
hf = scf (1);
hf.figure_name = "4.16.09D1";
ha = gca ();
ha.axes_visible="on";
ha.foreground = 5;
xfrect (0, 1, 1, 1);
xpause (5000000);
hf.figure_name = "4.16.09D2";
xclea ([0.2, 0.8, 0.6, 0.6]);
xpause (5000000);
hf.figure_name = "4.16.09D3";
ha.foreground = 6;
xfrect (0.3, 0.7, 0.4, 0.4);

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

4.16.50   La zone de rognage  / Area of clipping

clip_box
clip_status
Clipping
Rognage


La zone de rognage restreint l'affichage du motif graphique à une zone rectangulaire de la fenetre graphique.
The clipping area restricts the display of a graphic pattern to a rectangular area of the graphic window.

Le champ clip_box controle la taille de zone de rognage (xinf, ysup, largeur, hauteur) et le champ clip_state controle si le rognage est effectif (valeur "clipgrf" ou "on") ou est inhibé (valeur "off")
The field clip_box controls the size of the clipping area (xinf, ysup, widtht, height) and the field clip_state controls if the clipping is performed (value "clipgrf" or "on") or is inhibited (value "off").

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

disp ("4.16.50A");
hf = scf (1);
hf.figure_name = "4.16.50A1";
ha = gca ();
ha.axes_visible="on";
xarc (0, 1, 1, 1, 0, 23040);
hc = gce ();
hc.background = 5;
hc.fill_mode = "on";
hc.clip_state = "clipgrf";
hc.clip_box = [0.4, 0.6, 0.2, 0.6];
xpause (5000000);

hf.figure_name = "4.16.50A2";
hc.clip_box = [0.3, 0.7, 0.4, 0.7];
xpause (5000000);

hf.figure_name = "4.16.50A3";
hc.clip_box = [0.2, 0.8, 0.6, 0.8];
xpause (5000000);

hf.figure_name = "4.16.50A4";
hc.clip_box = [0.1, 0.9, 0.8, 0.9];
xpause (5000000);

hf.figure_name = "4.16.50A5";
hc.clip_box = [0, 1, 1, 1];

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











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

disp ("4.16.50B");
hf = scf (1);
hf.figure_name = "4.16.50B1";
ha = gca ();
ha.axes_visible="on";
xarc (0, 1, 1, 1, 0, 23040);
hc = gce ();
hc.background = 6;
hc.fill_mode = "on";
hc.clip_state = "clipgrf";
hc.clip_box = [0.4, 0.6, 0.2, 0.6];
xpause (5000000);

hf.figure_name = "4.16.50B2";
hc.clip_state = "off";
xpause (5000000);

hf.figure_name = "4.16.50B3";
hc.clip_state = "on";

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







4.16.51   Procedure xclip

clipgrf
xclip

La procédure xclip définit la zone de rognage (xinf, ysup, largeur, hauteur). Cette zone s'applique à toute la fenetre et à tous les motifs, définis antérieurement ou postérieurement.
The procedure xclip defines the clipping area (xinf, ysup, widtht, height). This area is applied to the whole window and to all patterns, previoulsly or subsequently defined.

xclip ("clipgrf") rétablit l'affichage pleine fenetre.

xclip ("clipgrf") restaures the display in the whole window.

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

disp ("4.16.51A");
hf = scf (1);
hf.figure_name = "4.16.51A1";
ha = gca ();
ha.axes_visible="on";
ha.box = "on";
xfrect ([0,1,1,1]);
hr = gce ();
hr.background = 3;
hr.fill_mode = "on";
xpause (5000000);

hf.figure_name = "4.16.51A2";
xclip ([-0.1, 0.5, 0.6, 0.6]);
xpause (5000000);

hf.figure_name = "4.16.51A3";
xarc (0, 1, 1, 1, 0, 23040);
hc = gce ();
hc.background = 5;
hc.fill_mode = "on";
xpause (5000000);

hf.figure_name = "4.16.51A4";
xclip ("clipgrf");

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









NB : la zone gérée par xclip s'applique a la fenetre entière  mais n'est pas accessible par le handle Figure.
NOTE: the area managed by xclip applies to the whole window, but cannot be accessed by the handle Figure.

4.16.52   xget ("clipping")  xset ("clipping")

clipping (xget, xset)
clipoff (xset)
xget ("clipping")
xset
("clipping")
xset ("clipoff")

La fonction xget ("clipping") retrourne la zone de rognage (xinf, ysup, largeur, hauteur). En voie d'obsolescence.
The function xget ("clipping") returns the clipping area (xinf, ysup, widtht, height). Becoming obsolete.

//  Program Spas41652A
//  Designed for Scilab 3.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.16.52A");
hf = scf (1);
hf.figure_name = "4.16.52A";
ha = gca ();
ha.axes_visible="on";
ha.box = "on";
xfrect ([0,1,1,1]);
hr = gce ();
hr.foreground = 3;
hr.fill_mode = "on";
xclip ([-0.1, 0.5, 0.6, 0.6]);
v = xget ("clipping"),

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



Interprétation ? BUG 1484

La procédure xclip ("clipping") définit la zone de rognage (xinf, ysup, largeur, hauteur). En voie d'obsolescence.
The procedure xclip ("clipping") defines the clipping area (xinf, ysup, widtht, height). Becoming obsolete.

//  Program Spas41652B
//  Designed for Scilab 3.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.16.52B");
hf = scf (1);
hf.figure_name = "4.16.52B";
ha = gca ();
ha.axes_visible="on";
ha.box = "on";
xfrect ([0,1,1,1]);
hr = gce ();
hr.foreground = 3;
hr.fill_mode = "on";
xset ("clipping",-0.1, 0.5, 0.6, 0.6);
v = xget ("clipping"),

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



La procédure xclip ("clipoff") rétablit l'affichage pleine fenetre graphique. En voie d'obsolescence.
The procedure xclip ("clipoff") restaures the displaying on the whole graphic window. Becoming obsolete.

//  Program Spas41652C
//  Designed for Scilab 3.0
//  Copyright Jacques-Deric Rouault, CNRS, INRIA

disp ("4.16.52C");
hf = scf (1);
hf.figure_name = "4.16.52C1";
ha = gca ();
ha.axes_visible="on";
ha.box = "on";
xfrect ([0,1,1,1]);
hr = gce ();
hr.foreground = 4;
hr.fill_mode = "on";
xset ("clipping",-0.1, 0.5, 0.6, 0.6);
xpause (5000000);

hf.figure_name = "4.16.52C2";
xset ("clipoff");

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

NB : la procédure xclip ("clipoff") ne marche pas BUG 1484
NOTE: the procedure xclip ("clipoff") does not work. BUG 1484

4.15       INITIALISATION  / INITIALIZATION
ALLER A L'INDEX GENERAL / GO TO THE GENERAL INDEX
ALLER A LA TABLE GENERALE / GO TO THE GENERAL TABLE
4.17       LA SOURIS GRAPHIQUE  / THE GRAPHIC MOUSE