Profil supprimé | Bonjour,
Je suis amateur en programmation, et j'ai peu d'expérience en graphique.
J'essaye de fair avec GtkAda, un arbre bianire à l'aide de Gtk.Ctree.
J'ai créé la fenêtre, et le ctree, et j'arrive tant bien que mal à construire un truc, mais :
J'ai pas le texte associé à chaque noeud.
J'ai pas l'image associée à chaque noeud.
Je voudrais vider l'arbre, je sais pas comment.
Bref, j'aurais besoin que quelqu'un jette un oeil à mon code.
Screen_shot :
Ce programme construit un arbre binaire contenant les réel 0.0 ou 1.0.
En gros pour 0.0 on ajoute à gauche, pour 1.0 on ajoute à droite.
Bref, j'ai un arbre bianire.
Je voudrais construire le tree folder à l'image de mon arbre bianire.
L'alogo général pour une itération après initialisation
- on ajoute le nouveau noeud.
- on appelle une fonction récursive de rétropropagation pour reconstruire l'arbre.
Voici la procédure récursive en question :
Code :
procedure Unfree(Main_Window : in out Main_Window_type) is Saved_Node : Node_Access := Main_Window.Next; Save_Ctree_Node : Gtk.Ctree.Gtk_Ctree_Node; Text : Interfaces.C.Strings.Chars_Ptr_Array (Title'Range); Style : Gtk.Style.Gtk_Style; Tmp_Color : Gdk.Color.Gdk_Color; use type Gtk_Ctree_Line_Style; begin Main_Window.Save_Left := Main_Window.Locale_Value; Main_Window.Save_Right := Main_Window.Locale_Value; if Main_Window.Next.Left /= null then Main_Window.Next := Main_Window.Next.Left; Unfree(Main_Window); end if; Main_Window.Locale_Value := Main_Window.Save_Left; Main_Window.Next := Saved_Node; declare procedure Get_Input(Pattern : in Positive; Input : out Node_Set; Desired : out Node_Set) is begin Input := (Main_Window.next.Node.Value(1), Main_Window.Save_left); Desired := (1 => 0.0); end Get_Input; package Binary_NN is new REM_NN(Num_Input_Nodes => 2, Num_Hidden_Nodes => 2, Num_Output_Nodes => 1, Num_Patterns => 1, New_Random_Weights => False, Input_To_Output_Connections => False, Weight_File_Name => "node 1.wgt", Get_Input => Get_Input); Response : Node_Set(1..1); begin Binary_NN.Respond(1, Response); Main_Window.Locale_Value := Response(1); if Main_Window.Locale_Value > 0.5 then Main_Window.Locale_Value := 1.0; else Main_Window.Locale_Value := 0.0; end if; Main_Window.Next.Node.Value(1) := Main_Window.Locale_Value; end; -- Ajouter un noeud Ctree Main_Window.parent := Gtk.Ctree.Insert_Node (Main_Window.Ctree, Parent => Main_Window.Parent, Sibling => Main_Window.Sibling, Text => Text, Spacing => 5, Pixmap_Closed => Pixmap1, Mask_Closed => Mask1, Pixmap_Opened => Pixmap2, Mask_Opened => Mask2, Is_Leaf => False, Expanded => False); if Main_Window.Locale_Value = 1.0 then Node_Set_Text(Main_Window.Ctree, Main_Window.Parent, 50, "Right" ); else Node_Set_Text(Main_Window.Ctree, Main_Window.Parent, 50, "Left" ); end if; Ctree_Style_Row_Data.Node_Set_Row_Data (Main_Window.Ctree, Node => Main_Window.parent, Data => Style); if Gtk.Ctree.Get_Line_Style (Main_Window.Ctree) = Ctree_Lines_Tabbed then Gtk.Ctree.Node_Set_Row_Style (Main_Window.Ctree, Node => Main_Window.parent, Style => Style); end if; Free (Text); if Main_Window.Locale_Value = 1.0 then put('1'); else put('0'); end if; if Main_Window.Next.Right /= null then Main_Window.Next := Main_Window.Next.Right; Unfree(Main_Window); end if; Main_Window.Next := Saved_Node; end Unfree;
|
Procedure d'initialisation (la parrtie sur l'initialisation du Ctree) :
Code :
Text := "Root" + ""; Gtk.Style.Gtk_New (Style); Gdk.Color.Set_Rgb (Tmp_Color, Red => 0, Green => 45_000, Blue => 55_000); Gtk.Style.Set_Base (Style, State_Type => State_Normal, Color => Tmp_Color); Ctree_Style_Row_Data.Node_Set_Row_Data (Main_Window.Ctree, Node => Main_Window.Parent, Data => Style); if Gtk.Ctree.Get_Line_Style (Main_Window.Ctree) = Ctree_Lines_Tabbed then Gtk.Ctree.Node_Set_Row_Style (Main_Window.Ctree, Node => Main_Window.Parent, Style => Style); end if; Main_Window.Parent := Gtk.Ctree.Insert_Node (Main_Window.Ctree, Parent => Gtk.Ctree.Null_Ctree_Node, Sibling => Gtk.Ctree.Null_Ctree_Node, Text => Text, Spacing => 5, Pixmap_Closed => Pixmap1, Mask_Closed => Mask1, Pixmap_Opened => Pixmap2, Mask_Opened => Mask2, Is_Leaf => False, Expanded => True); Free (Text); Put_Line(" : Sibling...Done...." ); Ctree_Style_Row_Data.Node_Set_Row_Data (Main_Window.Ctree, Node => Main_Window.Sibling, Data => Style); if Gtk.Ctree.Get_Line_Style (Main_Window.Ctree) = Ctree_Lines_Tabbed then Gtk.Ctree.Node_Set_Row_Style (Main_Window.Ctree, Node => Main_Window.Sibling, Style => Style); end if; Free (Text); Gtk.Ctree.Thaw (Main_Window.Ctree);
|
Mon problème je pense en premier lieu serait de comprendre le fonctionnement de Gtk.Ctree.Insert_Node.
Je dois mettre éventuellement deux dossier dans un. et ainsi de suite.
Merci pour votre aide. |