------------------------------------------- ------------------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- O C A R I N A . D I A . P R I N T E R . L A Y E R -- -- -- -- B o d y -- -- -- -- Copyright (C) 2005-2006, GET-Telecom Paris. -- -- -- -- Ocarina is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 2, or (at your option) any -- -- later version. Ocarina is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with Ocarina; see file COPYING. -- -- If not, write to the Free Software Foundation, 51 Franklin Street, Fifth -- -- Floor, Boston, MA 02111-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- Ocarina is maintained by the Ocarina team -- -- (ocarina-users@listes.enst.fr) -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; with DOM.Core; with DOM.Core.Documents; with DOM.Core.Nodes; with DOM.Core.Elements; with Ocarina.Nodes; with Ocarina.Nutils; with Ocarina.Dia.Printer.Objects; package body Ocarina.Dia.Printer.Layer is ------------------------------------- -- Find_Objects_AADL_Specification -- ------------------------------------- procedure Find_Objects_AADL_Specification (Doc : DOM.Core.document; Parent_Node : DOM.Core.node; Node : node_id; Id : Integer; Parent : Integer) is use Ocarina.Nutils; use Ada.Text_IO; use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; use Ocarina.Nodes; use Ocarina.Dia.Printer.Objects; pragma assert (Node /= No_Node); List_Node : node_id; Next_Id : Integer := Id; begin if not Is_Empty (Declarations (Node)) then List_Node := First_Node (Declarations (Node)); while Present (List_Node) loop case Kind (List_Node) is when k_component_type => Put_Line ("Component Type found"); Next_Id := Create_Component_Type (Doc, Parent_Node, List_Node, Next_Id, Parent); when k_component_implementation => Next_Id := Create_Component_Implementation (Doc, Parent_Node, List_Node, Next_Id, Parent); Put_Line ("Component Implementation found"); when k_port_group_type => Put_Line ("Port Group Type ignored"); when k_package_specification => Put_Line ("Package Specification ignored"); when k_property_set => Put_Line ("Property Set ignored"); when others => raise Program_Error; end case; List_Node := Next_Node (List_Node); end loop; end if; -- TODO : finish this function end Find_Objects_AADL_Specification; ----------------------- -- Find_Objects_Root -- ----------------------- procedure Find_Objects_Root (Doc : DOM.Core.document; Parent_Node : DOM.Core.node; Node : node_id; Id : Integer; Parent : Integer) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; use Ocarina.Dia.Printer.Objects; use Ocarina.Nodes; use Ada.Text_IO; pragma assert (Node /= No_Node); Next_Id : Integer; pragma warnings (Off, Next_Id); begin case Kind (Node) is when k_aadl_specification => Put_Line ("AADL Specification found"); Find_Objects_AADL_Specification (Doc, Parent_Node, Node, Id, Parent); when k_package_specification => Put_Line ("Package Specification ignored"); when k_component_type => Put_Line ("Component Type found"); Next_Id := Create_Component_Type (Doc, Parent_Node, Node, Id, Parent); when k_component_implementation => Put_Line ("Component Implementation ignored"); Next_Id := Create_Component_Implementation (Doc, Parent_Node, Node, Id, Parent); when k_port_group_type => Put_Line ("Group Type ignored"); when k_property_set => Put_Line ("Property Set ignored"); when others => Put_Line ("sortie non attendue de l'arbre"); null; end case; end Find_Objects_Root; ------------------ -- Create_Layer -- ------------------ procedure Create_Layer (Doc : DOM.Core.document; Parent_Node : DOM.Core.node; Node : node_id) is use DOM.Core.Nodes; use DOM.Core.Documents; use DOM.Core.Elements; use Ocarina.Nodes; use Ada.Text_IO; XML_Node : DOM.Core.node; XML_Element : constant DOM.Core.element := Create_Element (Doc, "dia:layer"); begin Set_Attribute (XML_Element, "name", "Background"); Set_Attribute (XML_Element, "visible", "true"); XML_Node := Append_Child (Parent_Node, XML_Element); Ada.Text_IO.Put_Line ("Creating Layer"); Find_Objects_Root (Doc, XML_Node, Node, 0, -1); -- build a table "XML_Node", "Node_Id" ??? -- Positioning Objects. -- Draw_Node_Simple (XML_Node, (3.0, 4.0)); -- Optimize Position. -- Optimize_Node (Doc, XML_Node, Node); end Create_Layer; end Ocarina.Dia.Printer.Layer;