--------------------------------------------------------------------------------------------------- -- Nom : Power_console / fait partie du programme Power Fractal -- -- -- -- Auteurs : Gregory Burri & Adrien Crivelli -- --------------------------------------------------------------------------------------------------- -- But : Outils de hauts niveau pour mettre a disposition de l'utilisateur les -- -- differentes fonction du programme -- --------------------------------------------------------------------------------------------------- with Ada.Text_IO; use Ada.Text_IO; with Ada.Long_Float_Text_Io; use Ada.Long_Float_Text_Io; with Ada.Integer_Text_Io; use Ada.Integer_Text_Io; with Power_Tools; use Power_Tools; with Power_Types; use Power_Types; with Power_Io; with Ada.Numerics.Discrete_Random; package body Power_Console is -- Type pour gerer un String de longueur indéfinie type T_Chaine is record Chaine : String(1 .. Longueur_Max) := (others => ' '); Longueur : Integer := 0; end record; --Les commandes a diposition type T_Commande is (Help, Info, Choose, Switch, Zoom, Zin, Zout, Center, Iteration, Limit, Cst, Angle, Color, Nbcolors, Random, Drawcolors, Default, Defaultlist, Auto, Draw, Anti, Render, Create, Del, Save, Load, Savelist, Loadlist, About, Quit); --Pour faire des entrees-sorties sur les commandes package T_Commande_Io is new Ada.Text_IO.Enumeration_IO(T_Commande); use T_Commande_Io; --Pour faire des entree-sortie sur le type byte package Modulo_IO is new Modular_IO (Byte); use Modulo_IO; --Pour faire des entrees-sorties sur le type T_Ensemble package T_Ensemble_IO is new Ada.Text_IO.Enumeration_IO(T_Ensemble); use T_Ensemble_IO; --Pour tirer une composante de couleur au hasard package Random_Composante is new Ada.Numerics.Discrete_Random(Byte); use Random_Composante; --La longeur d'une ligne d'aide Longeur_Ligne : constant := 60; --Contient l'aide pour une commande type T_Type_Info_Commandes is record Info_Para : String(1..Longeur_Ligne); --Parametres des commandes Info_Supp : String(1..Longeur_Ligne); --Decription des commandes end record; --Contient toute l'aide pour les commandes type T_Commande_Aide is array (T_Commande'range) of T_Type_Info_Commandes; Commande_Aide : constant T_Commande_Aide := ( Help => (" [] the stuff in brackets[] is not neccessary", " Im So Happy Cuz I Found My Friends... "), Info => (" ", " View some informations about the current fractal "), Choose => (" [] ", " Select a fractal in the list and draw it "), Switch => (" ", " Switch between Mandelbrot end Julia "), Zoom => (" [] ", " for zooming in the current fractal "), Zin => (" [] ", " Zoom in "), Zout => (" [] ", " Zoom out "), Center => (" [ ] ", " Center in a point of the fractal "), Iteration => (" ", " Set the number of iteration "), Limit => (" ", " Set the divergence limit "), Cst => (" ", " Set the complex number of 'c' (only for Julia) "), Angle => (" ", " Set the absolute value of angle "), Color => (" ( ) ", " Change one of colors. r, g and b are the channels "), Nbcolors => (" ", " Set numbers of colors "), Random => (" ", " Choice a randomize range of colors "), Drawcolors => (" <1> ! <0> ", " Set or unset the drawing of the range of colors "), Default => (" ", " Reset the current fractal "), Defaultlist => (" ", " Reset all fractals in the list "), Auto => (" <1> ! <0> ", " Set or unset the autoredraw "), Draw => (" ", " Draw the fractal "), Anti => (" <1> ! <0> ", " Set or unset the antialiasing "), Render => (" [ ] ", " Render the fractal in a bmp file. x y are the resolution "), Create => (" ", " Create a new fractal in the list "), Del => (" ", " View some informations about the curent fractal "), Save => (" ", " Save the current fractal in a file "), Load => (" ", " Load a fractal from a file "), Savelist => (" ", " Save the list of fractal in a file "), Loadlist => (" ", " Load a list of fractal from a file "), About => (" ", " ... and they're in my head "), Quit => (" ", " Quit Power Fractal ") ); -------------------------ERREURS------------------------ Erreur_Trop_Parametre : exception; -- La commande n'as pas besoin de parametre Erreur_Manque_Parametre : exception; -- La commande a besoin de parametre ------------------------------------------------------------------------------------------------ -- Nom : Verif_Extension -- -- But : Verifie si un string comporte une extension ou non, si non l'ajoute -- -- -- -- Parametres ---------------------------------------------------------------------------------- -- In : * Le nom du fichier a modifier : Nom_Fichier -- -- * L'extension du fichier : Extension -- -- -- -- Return : * Le string verifie, et modifier si il faut -- ------------------------------------------------------------------------------------------------ function Verif_Extension (Nom_Fichier : String; Extension : String) return String is --------------------------------------------------------------------------------------------- -- Nom : Tout_Minuscule -- -- But : Mettre tout les lettres d'un texte passe en parametre en minuscule -- --------------------------------------------------------------------------------------------- function Tout_Minuscule (Texte : in String) return String is --Une variable temporaire egal au string en entree Texte_Tmp : String (Texte'range) := Texte; --Variable Temporaire De 'Texte' --Le decalage entre les minuscules est les majuscules Decal_Min_Maj : constant := Character'Pos('a') - Character'Pos('A'); begin --Tout_Minuscule --Boucle parcourant tout les caracteres de Texte_Tmp for I in Texte_Tmp'First..Texte_Tmp'Last loop if Texte_Tmp(I) in 'A'..'Z' then --Si il tombe sur une majuscule alors --Convertie la majuscule en minuscule Texte_Tmp(I) := Character'Val( Character'Pos(Texte(I)) + Decal_Min_Maj ); end if; end loop; return Texte_Tmp; --Retourne la valeur modifie de Texte end Tout_Minuscule; --Nom du fichier plus l'ajout de l'extension Nom_Fichier_Ajout_Extension : String (1..Nom_Fichier'Length + Extension'Length); begin --Verif_Extension --Si la longueur du fichier est superieur a 4 (il y a la possibilite qu'il y ai l'extension) --et que l'extension est correct alors renvois le nom du fichier sans rien modifier if Nom_Fichier'Length > 4 and then Tout_Minuscule(Nom_Fichier(Nom_Fichier'Last - 3 .. Nom_Fichier'Last)) = "." & Tout_Minuscule(Extension) then return Nom_Fichier; else --Sinon ajoute l'extension return Nom_Fichier & "." & Tout_Minuscule(Extension); end if; end Verif_Extension; ------------------------------------------------------------------------------------------------ -- Nom : Parametre -- -- But : Determine si une commande est suivie d'un ou plusieurs parametre -- -- Parametres ---------------------------------------------------------------------------------- -- In : (aucun) -- -- -- -- return : * Si un (des) parametre existe : type : boolean -- ------------------------------------------------------------------------------------------------ function Parametre return Boolean is Cara : Character; Fin_Ligne : Boolean; begin -- Parametre -- Cherche un parametre Look_Ahead(Cara, Fin_Ligne); -- Tant que rencontre que des espace sur la ligne while Cara = Espace and not End_Of_Line loop Get(Cara); Look_Ahead(Cara, Fin_Ligne); end loop; return not Fin_Ligne; end Parametre; ------------------------------------------------------------------------------------------------ -- Nom : Get -- -- But : Lit un mot entier de caractere d'une longueur max de 50 -- -- Parametres ---------------------------------------------------------------------------------- -- In : (aucun) -- -- -- -- Out : * Un mot : type : T_Chaine -- ------------------------------------------------------------------------------------------------ procedure Get (Chaine : out T_Chaine) is Cara : Character; -- Caractere temporaire Fin_Ligne : Boolean; -- Si fin de ligne ou non begin Chaine.Longueur := 0; Look_Ahead(Cara, Fin_Ligne); -- Tant que le mot ou la ligne est pas fini while Cara /= Espace and not End_Of_Line loop Get(Cara); Chaine.Longueur := Chaine.Longueur + 1; Chaine.Chaine(Chaine.Longueur) := Cara; Look_Ahead(Cara, Fin_Ligne); end loop; end Get; ------------------------------------------------------------------------------------------------ -- Nom : Get -- -- But : Lit une couleur en RGB selon le format: ( R G B ) -- -- Parametres ---------------------------------------------------------------------------------- -- In : (aucun) -- -- -- -- Out : * Ue couleur : type : T_Couleur -- ------------------------------------------------------------------------------------------------ procedure Get (Couleur : out T_Couleur) is Cara : Character; Fin_Ligne : Boolean; begin -- Get if Parametre then Get(Cara); if Cara = '(' then -- Si existe lit chaque composante de la couleur if Parametre then Look_Ahead(Cara, Fin_Ligne); Get(Couleur.R); else raise Data_Error; end if; if Parametre then Get(Couleur.G); else raise Data_Error; end if; if Parametre then Get(Couleur.B); else raise Data_Error; end if; -- Toute les composante trouvee -> cherche la parenthese fermante if Parametre then -- Trouve la parenthese fermante Get(Cara); if Cara /= ')' then -- Pas de ')' raise Data_Error; end if; else -- Plus rien apres les 3 composante donc pas de ')' raise Data_Error; end if; else -- Pas de '(' raise Data_Error; end if; else -- Plus rien apres la commande raise Erreur_Manque_Parametre; end if; end Get; ------------------------------------------------------------------------------------------------ -- Nom : Get -- -- But : Lit un boolean entre au clavier (1 / 0) -- -- Parametres ---------------------------------------------------------------------------------- -- In : (aucun) -- -- -- -- Out : * Un booleen : type : boolean -- ------------------------------------------------------------------------------------------------ procedure Get (Flag : out Boolean) is Tmp : Integer; -- Variable temporaire pour la lecture begin -- Get Get(Tmp); Flag := Tmp = 1; if Tmp not in 0 .. 1 then raise Data_Error; end if; end Get; ------------------------------------------------------------------------------------------------ -- Nom : Console -- -- But : Gere une console avec commandes et parametre -- -- Parametres ---------------------------------------------------------------------------------- -- In : * le prompt utilise dans la console -- -- -- -- In out : La liste des fractals -- ------------------------------------------------------------------------------------------------ procedure Console(Liste : in out T_Liste_Fractals; Prompt : in String) is Courant : T_Lien := Fractal_Num(Liste, 1); -- Fractal courante de la liste Generateur_Composante : Generator; --Utilise pour tirer une composante au hasard Commande : T_Commande; -- La commande Facteur_Zoom : Long_Float; -- facteur en parametre a zoom Largeur : Integer; -- Pour la resolution du BMP Hauteur : Integer; -- Pour la resolution du BMP Nom : T_Chaine; -- Pour le nom du fichier BMP ou du POF Couleur : T_Couleur; -- Couleur (pour le changement de couleur) Numero : Positive; -- Numero/nombre de la couleur ou de la fractale a selectionner Long_Float_Tmp : Long_Float; -- Variable temporaire pour la saisie de 2 parametres long_float Auto_Rafraichi : Boolean := True; -- Si redessine a chaque changement de parametre Fractal_Change : Boolean := False; -- Si les parametres ont ete change par une commande Couleur_Change : Boolean := False; -- Si les couleurs ont change par une commande begin Courant := Fractal_Num(Liste, Choix_Mosaic(Liste)); Power_Tools.Dessiner_Fractal(Courant.Fractal); loop begin -- Saisie d'une commande correcte loop begin New_Line; Put(Prompt); Get(Commande); exit; exception when Data_Error => Skip_Line; New_Line; Put_Line(" Command unknown !"); Put(" ("); Put(T_Commande'First); Put_Line(" for details)"); end; end loop; case Commande is -- Aide when T_Commande'Val(0) => if Parametre then Get(Commande); Skip_Line; New_Line; Put(" "); Put(Commande); Put(Commande_Aide(Commande).Info_Para); New_Line; Put(Commande_Aide(Commande).Info_Supp); New_Line; else New_Line; for I in T_Commande'range loop Put(" "); Put(I); Put(Commande_Aide(I).Info_Para); New_Line; end loop; end if; -- Info when T_Commande'Val(1) => if Parametre then raise Erreur_Trop_Parametre; end if; New_Line; Put(" "); Put(Courant.Fractal.Ensemble); New_Line; Put(" Zoom : "); Put(Courant.Fractal.Zoom,0, 6, 0); New_Line; Put(" Divergence limit : "); Put(Courant.Fractal.C_Diverge_Limite,0 ,6, 0); New_Line; Put(" Iterations number : "); Put(Courant.Fractal.Nb_Iteration_Max, 0); New_Line; Put(" Center : ("); Put(Courant.Fractal.Centre.X, 0,6,0); Put(", "); Put(Courant.Fractal.Centre.Y, 0,6,0); Put(")"); New_Line; Put(" Angle : "); Put(Courant.Fractal.Angle, 0, 6, 0); New_Line; Put(" Antialiasing : "); if Courant.Fractal.Antialiasing then Put("yes"); else Put("no"); end if; New_Line; if Courant.Fractal.Ensemble = Julia then Put(" Constant : ("); Put(Courant.Fractal.Cx, 0,6,0); Put(", "); Put(Courant.Fractal.Cy, 0,6,0); Put(")"); New_Line; end if; Put(" Colors ("); Put(Courant.Fractal.Nb_Couleur, 2); Put(") :"); for I in Courant.Fractal.Couleur'range loop Put(" ("); Put(Courant.Fractal.Couleur(I).R, 3); Put(", "); Put(Courant.Fractal.Couleur(I).G, 3); Put(", "); Put(Courant.Fractal.Couleur(I).B, 3); Put(")"); New_Line; Put(" "); end loop; -- Choisir une fractal dans la liste when T_Commande'Val(2) => -- Si une seule fractale ne choisit pas if Nb_Fractals(Liste) > 1 then if Parametre then Get(Numero); Skip_Line; -- Si le numero existe: prends la fractal if Numero in 1 .. Nb_Fractals(Liste) then Courant := Fractal_Num(Liste, Numero); Fractal_Change:= True; else raise Data_Error; end if; else -- Aucun parametre: affiche le choix Courant := Fractal_Num(Liste, Choix_Mosaic(Liste)); Fractal_Change:= True; end if; else New_Line; Put_Line("There is only one fractal !"); end if; -- Echange entre les ensemblea when T_Commande'Val(3) => if Parametre then raise Erreur_Trop_Parametre; end if; if Courant.Fractal.Ensemble = Julia then Courant.Fractal := (Mandelbrot, Courant.Fractal.Nb_Couleur, Courant.Fractal.Nb_Iteration_Max, Courant.Fractal.C_Diverge_Limite, Courant.Fractal.Zoom, Courant.Fractal.Centre, Courant.Fractal.Angle, Courant.Fractal.Couleur, Courant.Fractal.Antialiasing, Courant.Fractal.Dessine_Degrade); else Courant.Fractal := (Julia, Courant.Fractal.Nb_Couleur, Courant.Fractal.Nb_Iteration_Max, Courant.Fractal.C_Diverge_Limite, Courant.Fractal.Zoom, Courant.Fractal.Centre, Courant.Fractal.Angle, Courant.Fractal.Couleur, Courant.Fractal.Antialiasing, Courant.Fractal.Dessine_Degrade, Fractal_Initial_Julia.Cx, Fractal_Initial_Julia.Cy); end if; Fractal_Change:= True; -- Zoom when T_Commande'Val(4) => -- si parametre trouve if Parametre then Get(Courant.Fractal.Zoom); -- Le zoom ne depasse pas la limite inferieure if Courant.Fractal.Zoom < Zoom_Min then Courant.Fractal.Zoom := Zoom_Min; end if; Fractal_Change := True; else Put_Line("Press ESC to return to console mode..."); -- Si la fractal affichee n'est plus actuelle: la redessine if Fractal_Change then Power_Tools.Dessiner_Fractal(Courant.Fractal); Fractal_Change := False; Couleur_Change := False; end if; Power_Tools.Zoom_Souris(Courant.Fractal); end if; Skip_Line; -- Zoom avant when T_Commande'Val(5) => if Parametre then Get(Facteur_Zoom); Courant.Fractal.Zoom := Courant.Fractal.Zoom * Facteur_Zoom; else Courant.Fractal.Zoom := Courant.Fractal.Zoom * Facteur_Zin; end if; -- Le zoom ne depasse pas la limite inferieure if Courant.Fractal.Zoom < Zoom_Min then Courant.Fractal.Zoom := Zoom_Min; end if; Skip_Line; Fractal_Change := True; -- Zoom arriere when T_Commande'Val(6) => if Parametre then Get(Facteur_Zoom); Courant.Fractal.Zoom := Courant.Fractal.Zoom / Facteur_Zoom; else Courant.Fractal.Zoom := Courant.Fractal.Zoom / Facteur_Zout; end if; -- Le zoom ne depasse pas la limite inferieure if Courant.Fractal.Zoom < Zoom_Min then Courant.Fractal.Zoom := Zoom_Min; end if; Skip_Line; Fractal_Change := True; -- Centrer la fractal when T_Commande'Val(7) => -- si parametre trouve if Parametre then Get(Long_Float_Tmp); if Parametre then Get(Courant.Fractal.Centre.Y); Skip_Line; Courant.Fractal.Centre.X := Long_Float_Tmp; Fractal_Change := True; else raise Erreur_Manque_Parametre; end if; else Put_Line("Press ESC to return to console mode..."); -- Si la fractal affichee n'est plus actuelle: la redessine if Fractal_Change then Power_Tools.Dessiner_Fractal(Courant.Fractal); Fractal_Change := False; Couleur_Change := False; end if; Power_Tools.Centrer(Courant.Fractal); end if; -- Nombre d'iteration when T_Commande'Val(8) => if not Parametre then raise Erreur_Manque_Parametre; end if; Get(Courant.Fractal.Nb_Iteration_Max); -- Le nb d'iteration ne depasse pas la limite inferieure if Courant.Fractal.Nb_Iteration_Max < Nb_Iteration_Min then Courant.Fractal.Nb_Iteration_Max := Nb_Iteration_Min; end if; Skip_Line; Fractal_Change := True; -- Limite de divergence when T_Commande'Val(9) => if not Parametre then raise Erreur_Manque_Parametre; end if; Get(Courant.Fractal.C_Diverge_Limite); Skip_Line; -- Limite la valeur if Courant.Fractal.C_Diverge_Limite < 0.0 then Courant.Fractal.C_Diverge_Limite := 0.0; elsif Courant.Fractal.C_Diverge_Limite > 4.0 then Courant.Fractal.C_Diverge_Limite := 4.0; end if; Fractal_Change := True; -- Constante pour le calcul de Julia when T_Commande'Val(10) => if Courant.Fractal.Ensemble = Julia then if Parametre then Get(Long_Float_Tmp); else raise Erreur_Manque_Parametre; end if; if Parametre then Get(Courant.Fractal.Cy); Courant.Fractal.Cx := Long_Float_Tmp; Fractal_Change := True; else raise Erreur_Manque_Parametre; end if; else New_Line; Put_Line(" Only with Julia set !"); end if; -- Rotation de la fractale when T_Commande'Val(11) => if Parametre then Get(Courant.Fractal.Angle); Skip_Line; if Courant.Fractal.Angle > 0.0 then while Courant.Fractal.Angle not in 0.0 .. 360.0 loop Courant.Fractal.Angle := Courant.Fractal.Angle - 360.0; end loop; else while Courant.Fractal.Angle not in 0.0 .. 360.0 loop Courant.Fractal.Angle := Courant.Fractal.Angle + 360.0; end loop; end if; Fractal_Change := True; else raise Erreur_Manque_Parametre; end if; -- Couleur par numero de la couleur when T_Commande'Val(12) => if Parametre then Get(Numero); else raise Erreur_Manque_Parametre; end if; -- Si le numero ne corespond a rien: erreur if Numero not in Courant.Fractal.Couleur'range then raise Data_Error; end if; if Parametre then Get(Courant.Fractal.Couleur(Numero)); Couleur_Change := True; else raise Erreur_Manque_Parametre; end if; -- Le nombre de couleur definie du degrade when T_Commande'Val(13) => if Parametre then Get(Numero); Skip_Line; if Numero < 2 then Numero := 2; elsif Numero > Nb_Couleur_Max then Numero := Nb_Couleur_Max; end if; -- Devient le nombre de couleur a ajouter (relatif, plus absolu) Numero := Numero - Courant.Fractal.Nb_Couleur; -- Redefinit la fractal avec le bon nombre de couleur if Courant.Fractal.Ensemble = Mandelbrot then Courant.Fractal := (Mandelbrot, Courant.Fractal.Nb_Couleur + Numero, Courant.Fractal.Nb_Iteration_Max, Courant.Fractal.C_Diverge_Limite, Courant.Fractal.Zoom, Courant.Fractal.Centre, Courant.Fractal.Angle, Courant.Fractal.Couleur( Courant.Fractal.Couleur'First .. Courant.Fractal.Nb_Couleur + Numero), Courant.Fractal.Antialiasing, Courant.Fractal.Dessine_Degrade); else Courant.Fractal := (Julia, Courant.Fractal.Nb_Couleur + Numero, Courant.Fractal.Nb_Iteration_Max, Courant.Fractal.C_Diverge_Limite, Courant.Fractal.Zoom, Courant.Fractal.Centre, Courant.Fractal.Angle, Courant.Fractal.Couleur( Courant.Fractal.Couleur'First .. Courant.Fractal.Nb_Couleur + Numero), Courant.Fractal.Antialiasing, Courant.Fractal.Dessine_Degrade, Courant.Fractal.Cx, Courant.Fractal.Cy); end if; -- Quand le nouveau nb de couleur est plus grand: repete la derniere -- couleur connue dans le reste des couleurs Courant.Fractal.Couleur(Courant.Fractal.Nb_Couleur - Numero + 1 .. Courant.Fractal.Couleur'Last) := (others => Courant.Fractal.Couleur(Courant.Fractal.Nb_Couleur - Numero)); Couleur_Change := True; else raise Erreur_Manque_Parametre; end if; -- Tire les couleurs au hasard when T_Commande'Val(14) => if Parametre then raise Erreur_Trop_Parametre; else Reset(Generateur_Composante); -- Tire au hasard chaque couleur de la composante for I in Courant.Fractal.Couleur'range loop Courant.Fractal.Couleur(I) := (Random(Generateur_Composante), Random(Generateur_Composante), Random(Generateur_Composante)); end loop; Couleur_Change := True; end if; -- Si dessine le degrade de couleur when T_Commande'Val(15) => if not Parametre then raise Erreur_Manque_Parametre; end if; Get(Courant.Fractal.Dessine_Degrade); Skip_Line; Couleur_Change := True; -- Reinitialise tous les parametres when T_Commande'Val(16) => if Parametre then raise Erreur_Trop_Parametre; end if; -- Inialise selon l'ensebmle de la fractal if Courant.Fractal.Ensemble = Julia then Courant.Fractal := Fractal_Initial_Julia; else Courant.Fractal := Fractal_Initial_Mandel; end if; Fractal_Change := True; -- Reprends la liste par defaut when T_Commande'Val(17) => if Parametre then raise Erreur_Trop_Parametre; else Liste := Liste_Defaut; Courant := Fractal_Num(Liste, Choix_Mosaic(Liste)); Fractal_Change:= True; end if; -- Rafraichissement automatique when T_Commande'Val(18) => if not Parametre then raise Erreur_Manque_Parametre; end if; Get(Auto_Rafraichi); Skip_Line; -- Dessine la fractale when T_Commande'Val(19) => if Parametre then raise Erreur_Trop_Parametre; end if; Power_Tools.Dessiner_Fractal(Courant.Fractal); Fractal_Change := False; Couleur_Change := False; -- Antialiasing when T_Commande'Val(20) => if not Parametre then -- Aucun parametre: erreur raise Erreur_Manque_Parametre; end if; Get(Courant.Fractal.Antialiasing); Skip_Line; Fractal_Change := True; -- Rendre dans un fichier BMP when T_Commande'Val(21) => if Parametre then -- Prends le premier parametre Get(Nom); else -- Aucun parametre: erreur raise Erreur_Manque_Parametre; end if; if Parametre then -- Prends le 2eme parametre Get(Largeur); if Parametre then -- Prends 3eme parametre et balance le reste Get(Hauteur); Skip_Line; -- Ajuste la resolution a min 5 et max 10'000 if Largeur < 5 then Largeur := 5; elsif Largeur > 10000 then Largeur := 10000; elsif Hauteur < 5 then Hauteur := 5; elsif Hauteur > 10000 then Hauteur := 10000; end if; -- 3 parametres lu correctement: crée le BMP avec la resolution demandée Power_Io.Rendre_Bmp (Courant.Fractal, Verif_Extension(Nom.Chaine(1 .. Nom.Longueur), "BMP"), Largeur, Hauteur); else -- 2 parametres raise Erreur_Manque_Parametre; end if; else -- 1 seul parametre: cree le BMP avec valeur par defaut Power_Io.Rendre_Bmp ( Courant.Fractal, Verif_Extension(Nom.Chaine(1 .. Nom.Longueur), "BMP")); end if; -- Cree une nouvelle fractal when T_Commande'Val(22) => if Parametre then raise Erreur_Trop_Parametre; else Ajouter(Liste, Fractal_Initial_Mandel); Courant := Fractal_Num(Liste, Nb_Fractals(Liste)); Fractal_Change:= True; end if; -- Supprime une fractal de la liste when T_Commande'Val(23) => if Nb_Fractals(Liste) > 1 then if Parametre then Get(Numero); Skip_Line; -- Si la fractal existe if Numero in 1 .. Nb_Fractals(Liste) then --Si veut effacer la fractal courante: change la courante if Courant = Fractal_Num(Liste, Numero) and Numero > 1 then Courant := Fractal_Num(Liste, Numero - 1); Fractal_Change := True; elsif Courant = Fractal_Num(Liste, Numero) and Numero = 1 then Courant := Fractal_Num(Liste, 2); Fractal_Change := True; end if; Effacer(Liste, Numero); else raise Data_Error; end if; -- Si aucun parametre else Numero := Choix_Mosaic(Liste); --Si veut effacer la fractal courante: change la courante if Courant = Fractal_Num(Liste, Numero) and Numero > 1 then Courant := Fractal_Num(Liste, Numero - 1); elsif Courant = Fractal_Num(Liste, Numero) and Numero = 1 then Courant := Fractal_Num(Liste, 2); end if; Effacer(Liste, Numero); Fractal_Change := True; end if; -- Si veux effacer la derniere fractal else skip_Line; New_Line; Put_Line("The last fractal can't be deleted !"); end if; -- Sauve les donnee de la fractale when T_Commande'Val(24) => if Parametre then Get(Nom); Skip_Line; Power_Io.Enregistrer_Fractal(Verif_Extension(Nom.Chaine(1 .. Nom.Longueur), "JOF"), Courant.Fractal); else raise Erreur_Manque_Parametre; end if; -- Charge les donnee de la fractale when T_Commande'Val(25) => if Parametre then Get(Nom); Skip_Line; -- Ajoute a la liste et la prend comme fractale courante Ajouter(Liste, Power_Io.Charger_Fractal (Verif_Extension(Nom.Chaine(1 .. Nom.Longueur), "JOF"))); Courant := Fractal_Num(Liste, Nb_Fractals(Liste)); Fractal_Change := True; else raise Erreur_Manque_Parametre; end if; -- Sauve les donnee de toute la liste when T_Commande'Val(26) => if Parametre then Get(Nom); Skip_Line; Power_Io.Enregistrer_Liste (Verif_Extension(Nom.Chaine(1 .. Nom.Longueur), "LOF"), Liste); else raise Erreur_Manque_Parametre; end if; -- Charge les donnee de toute la liste when T_Commande'Val(27) => if Parametre then Get(Nom); Skip_Line; Power_Io.Charger_Liste (Verif_Extension(Nom.Chaine(1 .. Nom.Longueur), "LOF"), Liste); Courant := Fractal_Num(Liste, Choix_Mosaic(Liste)); Fractal_Change := True; else raise Erreur_Manque_Parametre; end if; -- A propos du programme when T_Commande'Val(28) => if Parametre then raise Erreur_Trop_Parametre; end if; Skip_Line; Put_Line(" ____ ___ __ __ _____ ____"); Put_Line(" | _ \ / _ \\ \ / /| ____|| _ \ "); Put_Line(" | |_) || | | |\ \ /\ / / | _| | |_) |"); Put_Line(" | __/ | |_| | \ V V / | |___ | _ < "); Put_Line(" |_| \___/ \_/\_/ |_____||_| \_\"); New_Line; Put_Line(" _____ ____ _ ____ _____ _ _"); Put_Line(" | ___|| _ \ / \ / ___||_ _| / \ | |"); Put_Line(" | |_ | |_) | / _ \ | | | | / _ \ | |"); Put_Line(" | _| | _ < / ___ \| |___ | | / ___ \ | |__"); Put_Line(" |_| |_| \_\/_/ \_\\____| |_|/_/ \_\|____|"); Put_Line(" V 1.0"); Put_Line(" by G.Burri and A.Crivelli"); New_Line; Put_Line(" e-mail : greg.burri@net2000.ch"); Put_Line(" powerkiki@urbanet.ch"); New_Line; Put_Line(" Url : http://pifou.servehttp.com/powerfractal"); -- Quitte le programme when T_Commande'Val(29) => if Parametre then raise Erreur_Trop_Parametre; end if; Skip_Line; exit; end case; -- En mode auto: redessine la fractal si un ou plusieurs parametres ont change if Auto_Rafraichi and Fractal_Change then Power_Tools.Dessiner_Fractal(Courant.Fractal); Fractal_Change := False; Couleur_Change := False; -- En mode auto: redessine la fractal si les couleurs ont changé elsif Auto_Rafraichi and Couleur_Change then Power_Tools.Rafraichir_Couleur(Courant.Fractal); Couleur_Change := False; end if; exception when Erreur_Trop_Parametre => Skip_Line; New_Line; Put_Line(" Too much parameters !"); Put(" ("); Put(T_Commande'First); Put_Line(" for details)"); when Erreur_Manque_Parametre => Skip_Line; New_Line; Put_Line(" Parameter(s) missing !"); Put(" ("); Put(T_Commande'First); Put_Line(" for details)"); when Data_Error => Skip_Line; New_Line; Put_Line(" Bad parameter(s) !"); Put(" ("); Put(T_Commande'First); Put_Line(" for details)"); when Power_Io.Erreur_Fichier => New_Line; Put_Line(" File not found !"); end; end loop; end Console; end Power_Console;