1 ---------------------------------------------------------------------------------------------------
2 -- Nom : Power_console / fait partie du programme Power Fractal --
4 -- Auteurs : Gregory Burri & Adrien Crivelli --
5 ---------------------------------------------------------------------------------------------------
6 -- But : Outils de hauts niveau pour mettre a disposition de l'utilisateur les --
7 -- differentes fonction du programme --
8 ---------------------------------------------------------------------------------------------------
10 with Ada
.Text_IO
; use Ada
.Text_IO
;
11 with Ada
.Long_Float_Text_Io
; use Ada
.Long_Float_Text_Io
;
12 with Ada
.Integer_Text_Io
; use Ada
.Integer_Text_Io
;
14 with Power_Tools
; use Power_Tools
;
15 with Power_Types
; use Power_Types
;
17 with Ada
.Numerics
.Discrete_Random
;
20 package body Power_Console
is
22 -- Type pour gerer un String de longueur indéfinie
25 Chaine
: String(1 .. Longueur_Max
) := (others => ' ');
26 Longueur
: Integer := 0;
29 --Les commandes a diposition
30 type T_Commande
is (Help
, Info
, Choose
, Switch
, Zoom
, Zin
, Zout
, Center
, Iteration
, Limit
,
31 Cst
, Angle
, Color
, Nbcolors
, Random
, Drawcolors
, Default
, Defaultlist
,
32 Auto
, Draw
, Anti
, Render
, Create
, Del
, Save
, Load
, Savelist
, Loadlist
,
35 --Pour faire des entrees-sorties sur les commandes
36 package T_Commande_Io
is new Ada
.Text_IO
.Enumeration_IO(T_Commande
); use T_Commande_Io
;
39 --Pour faire des entree-sortie sur le type byte
40 package Modulo_IO
is new Modular_IO (Byte
); use Modulo_IO
;
42 --Pour faire des entrees-sorties sur le type T_Ensemble
43 package T_Ensemble_IO
is new Ada
.Text_IO
.Enumeration_IO(T_Ensemble
); use T_Ensemble_IO
;
45 --Pour tirer une composante de couleur au hasard
46 package Random_Composante
is new Ada
.Numerics
.Discrete_Random(Byte
); use Random_Composante
;
48 --La longeur d'une ligne d'aide
49 Longeur_Ligne
: constant := 60;
51 --Contient l'aide pour une commande
52 type T_Type_Info_Commandes
is
54 Info_Para
: String(1..Longeur_Ligne
); --Parametres des commandes
55 Info_Supp
: String(1..Longeur_Ligne
); --Decription des commandes
58 --Contient toute l'aide pour les commandes
59 type T_Commande_Aide
is array (T_Commande
'range) of T_Type_Info_Commandes
;
61 Commande_Aide
: constant T_Commande_Aide
:=
65 (" [<any commands>] the stuff in brackets[] is not neccessary",
66 " Im So Happy Cuz I Found My Friends... "),
70 " View some informations about the current fractal "),
73 (" [<number of a fractal in the list>] ",
74 " Select a fractal in the list and draw it "),
78 " Switch between Mandelbrot end Julia "),
81 (" [<Value of zoom>] ",
82 " for zooming in the current fractal "),
94 " Center in a point of the fractal "),
98 " Set the number of iteration "),
102 " Set the divergence limit "),
106 " Set the complex number of 'c' (only for Julia) "),
110 " Set the absolute value of angle "),
113 (" <number> (<r> <g> <b>) ",
114 " Change one of colors. r, g and b are the channels "),
118 " Set numbers of colors "),
122 " Choice a randomize range of colors "),
126 " Set or unset the drawing of the range of colors "),
130 " Reset the current fractal "),
134 " Reset all fractals in the list "),
137 " Set or unset the autoredraw "),
141 " Draw the fractal "),
145 " Set or unset the antialiasing "),
148 (" <name of file> [<x> <y>] ",
149 " Render the fractal in a bmp file. x y are the resolution "),
153 " Create a new fractal in the list "),
156 (" <number of a fractal in the list> ",
157 " View some informations about the curent fractal "),
161 " Save the current fractal in a file "),
165 " Load a fractal from a file "),
169 " Save the list of fractal in a file "),
173 " Load a list of fractal from a file "),
177 " ... and they're in my head "),
181 " Quit Power Fractal ")
185 -------------------------ERREURS------------------------
186 Erreur_Trop_Parametre
: exception; -- La commande n'as pas besoin de parametre
187 Erreur_Manque_Parametre
: exception; -- La commande a besoin de parametre
191 ------------------------------------------------------------------------------------------------
192 -- Nom : Verif_Extension --
193 -- But : Verifie si un string comporte une extension ou non, si non l'ajoute --
195 -- Parametres ----------------------------------------------------------------------------------
196 -- In : * Le nom du fichier a modifier : Nom_Fichier --
197 -- * L'extension du fichier : Extension --
199 -- Return : * Le string verifie, et modifier si il faut --
200 ------------------------------------------------------------------------------------------------
201 function Verif_Extension (Nom_Fichier
: String; Extension
: String) return String is
203 ---------------------------------------------------------------------------------------------
204 -- Nom : Tout_Minuscule --
205 -- But : Mettre tout les lettres d'un texte passe en parametre en minuscule --
206 ---------------------------------------------------------------------------------------------
207 function Tout_Minuscule (Texte
: in String) return String is
209 --Une variable temporaire egal au string en entree
210 Texte_Tmp
: String (Texte
'range) := Texte
; --Variable Temporaire De 'Texte'
212 --Le decalage entre les minuscules est les majuscules
213 Decal_Min_Maj
: constant := Character'Pos('a') - Character'Pos('A');
215 begin --Tout_Minuscule
217 --Boucle parcourant tout les caracteres de Texte_Tmp
218 for I
in Texte_Tmp
'First..Texte_Tmp
'Last loop
220 if Texte_Tmp(I
) in 'A'..'Z' then --Si il tombe sur une majuscule alors
222 --Convertie la majuscule en minuscule
223 Texte_Tmp(I
) := Character'Val( Character'Pos(Texte(I
)) + Decal_Min_Maj
);
228 return Texte_Tmp
; --Retourne la valeur modifie de Texte
231 --Nom du fichier plus l'ajout de l'extension
232 Nom_Fichier_Ajout_Extension
: String (1..Nom_Fichier
'Length + Extension
'Length);
234 begin --Verif_Extension
236 --Si la longueur du fichier est superieur a 4 (il y a la possibilite qu'il y ai l'extension)
237 --et que l'extension est correct alors renvois le nom du fichier sans rien modifier
238 if Nom_Fichier
'Length > 4 and then
239 Tout_Minuscule(Nom_Fichier(Nom_Fichier
'Last - 3 .. Nom_Fichier
'Last)) =
240 "." & Tout_Minuscule(Extension
) then
243 else --Sinon ajoute l'extension
244 return Nom_Fichier
& "." & Tout_Minuscule(Extension
);
250 ------------------------------------------------------------------------------------------------
251 -- Nom : Parametre --
252 -- But : Determine si une commande est suivie d'un ou plusieurs parametre --
253 -- Parametres ----------------------------------------------------------------------------------
256 -- return : * Si un (des) parametre existe : type : boolean --
257 ------------------------------------------------------------------------------------------------
258 function Parametre
return Boolean is
262 -- Cherche un parametre
263 Look_Ahead(Cara
, Fin_Ligne
);
264 -- Tant que rencontre que des espace sur la ligne
265 while Cara
= Espace
and not End_Of_Line
loop
267 Look_Ahead(Cara
, Fin_Ligne
);
269 return not Fin_Ligne
;
273 ------------------------------------------------------------------------------------------------
275 -- But : Lit un mot entier de caractere d'une longueur max de 50 --
276 -- Parametres ----------------------------------------------------------------------------------
279 -- Out : * Un mot : type : T_Chaine --
280 ------------------------------------------------------------------------------------------------
281 procedure Get (Chaine
: out T_Chaine
) is
282 Cara
: Character; -- Caractere temporaire
283 Fin_Ligne
: Boolean; -- Si fin de ligne ou non
285 Chaine
.Longueur
:= 0;
286 Look_Ahead(Cara
, Fin_Ligne
);
287 -- Tant que le mot ou la ligne est pas fini
288 while Cara
/= Espace
and not End_Of_Line
loop
290 Chaine
.Longueur
:= Chaine
.Longueur
+ 1;
291 Chaine
.Chaine(Chaine
.Longueur
) := Cara
;
292 Look_Ahead(Cara
, Fin_Ligne
);
298 ------------------------------------------------------------------------------------------------
300 -- But : Lit une couleur en RGB selon le format: ( R G B ) --
301 -- Parametres ----------------------------------------------------------------------------------
304 -- Out : * Ue couleur : type : T_Couleur --
305 ------------------------------------------------------------------------------------------------
306 procedure Get (Couleur
: out T_Couleur
) is
315 -- Si existe lit chaque composante de la couleur
317 Look_Ahead(Cara
, Fin_Ligne
);
333 -- Toute les composante trouvee -> cherche la parenthese fermante
335 -- Trouve la parenthese fermante
342 -- Plus rien apres les 3 composante donc pas de ')'
350 -- Plus rien apres la commande
351 raise Erreur_Manque_Parametre
;
357 ------------------------------------------------------------------------------------------------
359 -- But : Lit un boolean entre au clavier (1 / 0) --
360 -- Parametres ----------------------------------------------------------------------------------
363 -- Out : * Un booleen : type : boolean --
364 ------------------------------------------------------------------------------------------------
365 procedure Get (Flag
: out Boolean) is
366 Tmp
: Integer; -- Variable temporaire pour la lecture
370 if Tmp
not in 0 .. 1 then
376 ------------------------------------------------------------------------------------------------
378 -- But : Gere une console avec commandes et parametre --
379 -- Parametres ----------------------------------------------------------------------------------
380 -- In : * le prompt utilise dans la console --
382 -- In out : La liste des fractals --
383 ------------------------------------------------------------------------------------------------
384 procedure Console(Liste
: in out T_Liste_Fractals
; Prompt
: in String) is
385 Courant
: T_Lien
:= Fractal_Num(Liste
, 1); -- Fractal courante de la liste
387 Generateur_Composante
: Generator
; --Utilise pour tirer une composante au hasard
389 Commande
: T_Commande
; -- La commande
391 Facteur_Zoom
: Long_Float; -- facteur en parametre a zoom
392 Largeur
: Integer; -- Pour la resolution du BMP
393 Hauteur
: Integer; -- Pour la resolution du BMP
394 Nom
: T_Chaine
; -- Pour le nom du fichier BMP ou du POF
395 Couleur
: T_Couleur
; -- Couleur (pour le changement de couleur)
396 Numero
: Positive; -- Numero/nombre de la couleur ou de la fractale a selectionner
397 Long_Float_Tmp
: Long_Float; -- Variable temporaire pour la saisie de 2 parametres long_float
399 Auto_Rafraichi
: Boolean := True; -- Si redessine a chaque changement de parametre
400 Fractal_Change
: Boolean := False; -- Si les parametres ont ete change par une commande
401 Couleur_Change
: Boolean := False; -- Si les couleurs ont change par une commande
405 Courant
:= Fractal_Num(Liste
, Choix_Mosaic(Liste
));
406 Power_Tools
.Dessiner_Fractal(Courant
.Fractal
);
411 -- Saisie d'une commande correcte
422 Put_Line(" Command unknown !");
424 Put(T_Commande
'First);
425 Put_Line(" for details)");
432 when T_Commande
'Val(0) =>
439 Put(Commande_Aide(Commande
).Info_Para
);
441 Put(Commande_Aide(Commande
).Info_Supp
);
446 for I
in T_Commande
'range loop
449 Put(Commande_Aide(I
).Info_Para
);
456 when T_Commande
'Val(1) =>
458 raise Erreur_Trop_Parametre
;
463 Put(Courant
.Fractal
.Ensemble
);
467 Put(Courant
.Fractal
.Zoom
,0, 6, 0);
470 Put(" Divergence limit : ");
471 Put(Courant
.Fractal
.C_Diverge_Limite
,0 ,6, 0);
474 Put(" Iterations number : ");
475 Put(Courant
.Fractal
.Nb_Iteration_Max
, 0);
479 Put(Courant
.Fractal
.Centre
.X
, 0,6,0);
481 Put(Courant
.Fractal
.Centre
.Y
, 0,6,0);
486 Put(Courant
.Fractal
.Angle
, 0, 6, 0);
490 Put(" Antialiasing : ");
491 if Courant
.Fractal
.Antialiasing
then
498 if Courant
.Fractal
.Ensemble
= Julia
then
499 Put(" Constant : (");
500 Put(Courant
.Fractal
.Cx
, 0,6,0);
502 Put(Courant
.Fractal
.Cy
, 0,6,0);
508 Put(Courant
.Fractal
.Nb_Couleur
, 2);
510 for I
in Courant
.Fractal
.Couleur
'range loop
512 Put(Courant
.Fractal
.Couleur(I
).R
, 3);
514 Put(Courant
.Fractal
.Couleur(I
).G
, 3);
516 Put(Courant
.Fractal
.Couleur(I
).B
, 3);
523 -- Choisir une fractal dans la liste
524 when T_Commande
'Val(2) =>
525 -- Si une seule fractale ne choisit pas
526 if Nb_Fractals(Liste
) > 1 then
530 -- Si le numero existe: prends la fractal
531 if Numero
in 1 .. Nb_Fractals(Liste
) then
532 Courant
:= Fractal_Num(Liste
, Numero
);
533 Fractal_Change
:= True;
538 -- Aucun parametre: affiche le choix
539 Courant
:= Fractal_Num(Liste
, Choix_Mosaic(Liste
));
540 Fractal_Change
:= True;
545 Put_Line("There is only one fractal !");
549 -- Echange entre les ensemblea
550 when T_Commande
'Val(3) =>
552 raise Erreur_Trop_Parametre
;
554 if Courant
.Fractal
.Ensemble
= Julia
then
555 Courant
.Fractal
:= (Mandelbrot
, Courant
.Fractal
.Nb_Couleur
,
556 Courant
.Fractal
.Nb_Iteration_Max
,
557 Courant
.Fractal
.C_Diverge_Limite
, Courant
.Fractal
.Zoom
,
558 Courant
.Fractal
.Centre
, Courant
.Fractal
.Angle
,
559 Courant
.Fractal
.Couleur
, Courant
.Fractal
.Antialiasing
,
560 Courant
.Fractal
.Dessine_Degrade
);
562 Courant
.Fractal
:= (Julia
, Courant
.Fractal
.Nb_Couleur
,
563 Courant
.Fractal
.Nb_Iteration_Max
,
564 Courant
.Fractal
.C_Diverge_Limite
, Courant
.Fractal
.Zoom
,
565 Courant
.Fractal
.Centre
, Courant
.Fractal
.Angle
,
566 Courant
.Fractal
.Couleur
, Courant
.Fractal
.Antialiasing
,
567 Courant
.Fractal
.Dessine_Degrade
,
568 Fractal_Initial_Julia
.Cx
, Fractal_Initial_Julia
.Cy
);
570 Fractal_Change
:= True;
574 when T_Commande
'Val(4) =>
576 -- si parametre trouve
578 Get(Courant
.Fractal
.Zoom
);
580 -- Le zoom ne depasse pas la limite inferieure
581 if Courant
.Fractal
.Zoom
< Zoom_Min
then
582 Courant
.Fractal
.Zoom
:= Zoom_Min
;
584 Fractal_Change
:= True;
586 Put_Line("Press ESC to return to console mode...");
587 -- Si la fractal affichee n'est plus actuelle: la redessine
588 if Fractal_Change
then
589 Power_Tools
.Dessiner_Fractal(Courant
.Fractal
);
590 Fractal_Change
:= False;
591 Couleur_Change
:= False;
593 Power_Tools
.Zoom_Souris(Courant
.Fractal
);
599 when T_Commande
'Val(5) =>
602 Courant
.Fractal
.Zoom
:= Courant
.Fractal
.Zoom
* Facteur_Zoom
;
604 Courant
.Fractal
.Zoom
:= Courant
.Fractal
.Zoom
* Facteur_Zin
;
607 -- Le zoom ne depasse pas la limite inferieure
608 if Courant
.Fractal
.Zoom
< Zoom_Min
then
609 Courant
.Fractal
.Zoom
:= Zoom_Min
;
612 Fractal_Change
:= True;
616 when T_Commande
'Val(6) =>
619 Courant
.Fractal
.Zoom
:= Courant
.Fractal
.Zoom
/ Facteur_Zoom
;
621 Courant
.Fractal
.Zoom
:= Courant
.Fractal
.Zoom
/ Facteur_Zout
;
624 -- Le zoom ne depasse pas la limite inferieure
625 if Courant
.Fractal
.Zoom
< Zoom_Min
then
626 Courant
.Fractal
.Zoom
:= Zoom_Min
;
629 Fractal_Change
:= True;
632 -- Centrer la fractal
633 when T_Commande
'Val(7) =>
635 -- si parametre trouve
639 Get(Courant
.Fractal
.Centre
.Y
);
641 Courant
.Fractal
.Centre
.X
:= Long_Float_Tmp
;
642 Fractal_Change
:= True;
644 raise Erreur_Manque_Parametre
;
647 Put_Line("Press ESC to return to console mode...");
648 -- Si la fractal affichee n'est plus actuelle: la redessine
649 if Fractal_Change
then
650 Power_Tools
.Dessiner_Fractal(Courant
.Fractal
);
651 Fractal_Change
:= False;
652 Couleur_Change
:= False;
654 Power_Tools
.Centrer(Courant
.Fractal
);
658 -- Nombre d'iteration
659 when T_Commande
'Val(8) =>
660 if not Parametre
then
661 raise Erreur_Manque_Parametre
;
663 Get(Courant
.Fractal
.Nb_Iteration_Max
);
665 -- Le nb d'iteration ne depasse pas la limite inferieure
666 if Courant
.Fractal
.Nb_Iteration_Max
< Nb_Iteration_Min
then
667 Courant
.Fractal
.Nb_Iteration_Max
:= Nb_Iteration_Min
;
670 Fractal_Change
:= True;
673 -- Limite de divergence
674 when T_Commande
'Val(9) =>
675 if not Parametre
then
676 raise Erreur_Manque_Parametre
;
678 Get(Courant
.Fractal
.C_Diverge_Limite
);
681 if Courant
.Fractal
.C_Diverge_Limite
< 0.0 then
682 Courant
.Fractal
.C_Diverge_Limite
:= 0.0;
683 elsif Courant
.Fractal
.C_Diverge_Limite
> 4.0 then
684 Courant
.Fractal
.C_Diverge_Limite
:= 4.0;
686 Fractal_Change
:= True;
690 -- Constante pour le calcul de Julia
691 when T_Commande
'Val(10) =>
692 if Courant
.Fractal
.Ensemble
= Julia
then
696 raise Erreur_Manque_Parametre
;
699 Get(Courant
.Fractal
.Cy
);
700 Courant
.Fractal
.Cx
:= Long_Float_Tmp
;
701 Fractal_Change
:= True;
703 raise Erreur_Manque_Parametre
;
707 Put_Line(" Only with Julia set !");
711 -- Rotation de la fractale
712 when T_Commande
'Val(11) =>
714 Get(Courant
.Fractal
.Angle
);
717 if Courant
.Fractal
.Angle
> 0.0 then
718 while Courant
.Fractal
.Angle
not in 0.0 .. 360.0 loop
719 Courant
.Fractal
.Angle
:= Courant
.Fractal
.Angle
- 360.0;
722 while Courant
.Fractal
.Angle
not in 0.0 .. 360.0 loop
723 Courant
.Fractal
.Angle
:= Courant
.Fractal
.Angle
+ 360.0;
727 Fractal_Change
:= True;
729 raise Erreur_Manque_Parametre
;
733 -- Couleur par numero de la couleur
734 when T_Commande
'Val(12) =>
738 raise Erreur_Manque_Parametre
;
741 -- Si le numero ne corespond a rien: erreur
742 if Numero
not in Courant
.Fractal
.Couleur
'range then
747 Get(Courant
.Fractal
.Couleur(Numero
));
748 Couleur_Change
:= True;
750 raise Erreur_Manque_Parametre
;
754 -- Le nombre de couleur definie du degrade
755 when T_Commande
'Val(13) =>
761 elsif Numero
> Nb_Couleur_Max
then
762 Numero
:= Nb_Couleur_Max
;
764 -- Devient le nombre de couleur a ajouter (relatif, plus absolu)
765 Numero
:= Numero
- Courant
.Fractal
.Nb_Couleur
;
767 -- Redefinit la fractal avec le bon nombre de couleur
768 if Courant
.Fractal
.Ensemble
= Mandelbrot
then
769 Courant
.Fractal
:= (Mandelbrot
, Courant
.Fractal
.Nb_Couleur
+ Numero
,
770 Courant
.Fractal
.Nb_Iteration_Max
,
771 Courant
.Fractal
.C_Diverge_Limite
,
772 Courant
.Fractal
.Zoom
, Courant
.Fractal
.Centre
,
773 Courant
.Fractal
.Angle
, Courant
.Fractal
.Couleur(
774 Courant
.Fractal
.Couleur
'First ..
775 Courant
.Fractal
.Nb_Couleur
+ Numero
),
776 Courant
.Fractal
.Antialiasing
,
777 Courant
.Fractal
.Dessine_Degrade
);
779 Courant
.Fractal
:= (Julia
, Courant
.Fractal
.Nb_Couleur
+ Numero
,
780 Courant
.Fractal
.Nb_Iteration_Max
,
781 Courant
.Fractal
.C_Diverge_Limite
,
782 Courant
.Fractal
.Zoom
, Courant
.Fractal
.Centre
,
783 Courant
.Fractal
.Angle
, Courant
.Fractal
.Couleur(
784 Courant
.Fractal
.Couleur
'First ..
785 Courant
.Fractal
.Nb_Couleur
+ Numero
),
786 Courant
.Fractal
.Antialiasing
,
787 Courant
.Fractal
.Dessine_Degrade
,
788 Courant
.Fractal
.Cx
, Courant
.Fractal
.Cy
);
791 -- Quand le nouveau nb de couleur est plus grand: repete la derniere
792 -- couleur connue dans le reste des couleurs
793 Courant
.Fractal
.Couleur(Courant
.Fractal
.Nb_Couleur
- Numero
+ 1 ..
794 Courant
.Fractal
.Couleur
'Last) := (others =>
795 Courant
.Fractal
.Couleur(Courant
.Fractal
.Nb_Couleur
- Numero
));
796 Couleur_Change
:= True;
798 raise Erreur_Manque_Parametre
;
802 -- Tire les couleurs au hasard
803 when T_Commande
'Val(14) =>
805 raise Erreur_Trop_Parametre
;
807 Reset(Generateur_Composante
);
808 -- Tire au hasard chaque couleur de la composante
809 for I
in Courant
.Fractal
.Couleur
'range loop
810 Courant
.Fractal
.Couleur(I
) := (Random(Generateur_Composante
),
811 Random(Generateur_Composante
), Random(Generateur_Composante
));
813 Couleur_Change
:= True;
817 -- Si dessine le degrade de couleur
818 when T_Commande
'Val(15) =>
819 if not Parametre
then
820 raise Erreur_Manque_Parametre
;
822 Get(Courant
.Fractal
.Dessine_Degrade
);
824 Couleur_Change
:= True;
827 -- Reinitialise tous les parametres
828 when T_Commande
'Val(16) =>
830 raise Erreur_Trop_Parametre
;
832 -- Inialise selon l'ensebmle de la fractal
833 if Courant
.Fractal
.Ensemble
= Julia
then
834 Courant
.Fractal
:= Fractal_Initial_Julia
;
836 Courant
.Fractal
:= Fractal_Initial_Mandel
;
838 Fractal_Change
:= True;
841 -- Reprends la liste par defaut
842 when T_Commande
'Val(17) =>
844 raise Erreur_Trop_Parametre
;
846 Liste
:= Liste_Defaut
;
847 Courant
:= Fractal_Num(Liste
, Choix_Mosaic(Liste
));
848 Fractal_Change
:= True;
852 -- Rafraichissement automatique
853 when T_Commande
'Val(18) =>
854 if not Parametre
then
855 raise Erreur_Manque_Parametre
;
861 -- Dessine la fractale
862 when T_Commande
'Val(19) =>
864 raise Erreur_Trop_Parametre
;
866 Power_Tools
.Dessiner_Fractal(Courant
.Fractal
);
867 Fractal_Change
:= False;
868 Couleur_Change
:= False;
872 when T_Commande
'Val(20) =>
873 if not Parametre
then
874 -- Aucun parametre: erreur
875 raise Erreur_Manque_Parametre
;
877 Get(Courant
.Fractal
.Antialiasing
);
879 Fractal_Change
:= True;
882 -- Rendre dans un fichier BMP
883 when T_Commande
'Val(21) =>
885 -- Prends le premier parametre
888 -- Aucun parametre: erreur
889 raise Erreur_Manque_Parametre
;
893 -- Prends le 2eme parametre
896 -- Prends 3eme parametre et balance le reste
900 -- Ajuste la resolution a min 5 et max 10'000
903 elsif Largeur
> 10000 then
905 elsif Hauteur
< 5 then
907 elsif Hauteur
> 10000 then
911 -- 3 parametres lu correctement: crée le BMP avec la resolution demandée
912 Power_Io
.Rendre_Bmp (Courant
.Fractal
,
913 Verif_Extension(Nom
.Chaine(1 .. Nom
.Longueur
), "BMP"),
917 raise Erreur_Manque_Parametre
;
920 -- 1 seul parametre: cree le BMP avec valeur par defaut
921 Power_Io
.Rendre_Bmp ( Courant
.Fractal
,
922 Verif_Extension(Nom
.Chaine(1 .. Nom
.Longueur
), "BMP"));
926 -- Cree une nouvelle fractal
927 when T_Commande
'Val(22) =>
929 raise Erreur_Trop_Parametre
;
931 Ajouter(Liste
, Fractal_Initial_Mandel
);
932 Courant
:= Fractal_Num(Liste
, Nb_Fractals(Liste
));
933 Fractal_Change
:= True;
937 -- Supprime une fractal de la liste
938 when T_Commande
'Val(23) =>
939 if Nb_Fractals(Liste
) > 1 then
943 -- Si la fractal existe
944 if Numero
in 1 .. Nb_Fractals(Liste
) then
946 --Si veut effacer la fractal courante: change la courante
947 if Courant
= Fractal_Num(Liste
, Numero
) and Numero
> 1 then
948 Courant
:= Fractal_Num(Liste
, Numero
- 1);
949 Fractal_Change
:= True;
950 elsif Courant
= Fractal_Num(Liste
, Numero
) and Numero
= 1 then
951 Courant
:= Fractal_Num(Liste
, 2);
952 Fractal_Change
:= True;
955 Effacer(Liste
, Numero
);
959 -- Si aucun parametre
961 Numero
:= Choix_Mosaic(Liste
);
962 --Si veut effacer la fractal courante: change la courante
963 if Courant
= Fractal_Num(Liste
, Numero
) and Numero
> 1 then
964 Courant
:= Fractal_Num(Liste
, Numero
- 1);
965 elsif Courant
= Fractal_Num(Liste
, Numero
) and Numero
= 1 then
966 Courant
:= Fractal_Num(Liste
, 2);
968 Effacer(Liste
, Numero
);
969 Fractal_Change
:= True;
971 -- Si veux effacer la derniere fractal
974 Put_Line("The last fractal can't be deleted !");
979 -- Sauve les donnee de la fractale
980 when T_Commande
'Val(24) =>
984 Power_Io
.Enregistrer_Fractal(Verif_Extension(Nom
.Chaine(1 .. Nom
.Longueur
),
985 "JOF"), Courant
.Fractal
);
987 raise Erreur_Manque_Parametre
;
991 -- Charge les donnee de la fractale
992 when T_Commande
'Val(25) =>
996 -- Ajoute a la liste et la prend comme fractale courante
997 Ajouter(Liste
, Power_Io
.Charger_Fractal
998 (Verif_Extension(Nom
.Chaine(1 .. Nom
.Longueur
), "JOF")));
1000 Courant
:= Fractal_Num(Liste
, Nb_Fractals(Liste
));
1001 Fractal_Change
:= True;
1003 raise Erreur_Manque_Parametre
;
1010 -- Sauve les donnee de toute la liste
1011 when T_Commande
'Val(26) =>
1015 Power_Io
.Enregistrer_Liste
1016 (Verif_Extension(Nom
.Chaine(1 .. Nom
.Longueur
), "LOF"), Liste
);
1018 raise Erreur_Manque_Parametre
;
1022 -- Charge les donnee de toute la liste
1023 when T_Commande
'Val(27) =>
1027 Power_Io
.Charger_Liste
1028 (Verif_Extension(Nom
.Chaine(1 .. Nom
.Longueur
), "LOF"), Liste
);
1030 Courant
:= Fractal_Num(Liste
, Choix_Mosaic(Liste
));
1031 Fractal_Change
:= True;
1033 raise Erreur_Manque_Parametre
;
1037 -- A propos du programme
1038 when T_Commande
'Val(28) =>
1040 raise Erreur_Trop_Parametre
;
1043 Put_Line(" ____ ___ __ __ _____ ____");
1044 Put_Line(" | _ \ / _ \\ \ / /| ____|| _ \ ");
1045 Put_Line(" | |_) || | | |\ \ /\ / / | _| | |_) |");
1046 Put_Line(" | __/ | |_| | \ V V / | |___ | _ < ");
1047 Put_Line(" |_| \___/ \_/\_/ |_____||_| \_\");
1049 Put_Line(" _____ ____ _ ____ _____ _ _
");
1050 Put_Line(" | ___|| _
\ / \ / ___||_ _|
/ \ | |
");
1051 Put_Line(" | |_ | |_
) |
/ _
\ | | | |
/ _
\ | |
");
1052 Put_Line(" | _| | _
< / ___
\| |___ | |
/ ___
\ | |__
");
1053 Put_Line(" |_| |_|
\_\/_
/ \_\\____| |_|
/_
/ \_\|____|
");
1055 Put_Line(" by G
.Burri
and A
.Crivelli
");
1057 Put_Line(" e
-mail
: greg
.burri@net2000
.ch
");
1058 Put_Line(" powerkiki@urbanet
.ch
");
1060 Put_Line(" Url
: http
://pifou
.servehttp
.com
/powerfractal
");
1063 -- Quitte le programme
1064 when T_Commande'Val(29) =>
1066 raise Erreur_Trop_Parametre;
1074 -- En mode auto: redessine la fractal si un ou plusieurs parametres ont change
1075 if Auto_Rafraichi and Fractal_Change then
1076 Power_Tools.Dessiner_Fractal(Courant.Fractal);
1077 Fractal_Change := False;
1078 Couleur_Change := False;
1079 -- En mode auto: redessine la fractal si les couleurs ont changé
1080 elsif Auto_Rafraichi and Couleur_Change then
1081 Power_Tools.Rafraichir_Couleur(Courant.Fractal);
1082 Couleur_Change := False;
1087 when Erreur_Trop_Parametre =>
1090 Put_Line(" Too much parameters
!");
1092 Put(T_Commande'First);
1093 Put_Line(" for details
)");
1095 when Erreur_Manque_Parametre =>
1098 Put_Line(" Parameter(s
) missing
!");
1100 Put(T_Commande'First);
1101 Put_Line(" for details
)");
1106 Put_Line(" Bad
parameter(s
) !");
1108 Put(T_Commande'First);
1109 Put_Line(" for details
)");
1111 when Power_Io.Erreur_Fichier =>
1113 Put_Line(" File
not found
!");