---------------------------------------------- ---------------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- O C A R I N A . D I A . P R I N T E R . O P T I M I Z E -- -- -- -- S p e c -- -- -- -- Copyright (C) 2005-2007, 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) -- -- -- ------------------------------------------------------------------------------ -- This package contains the top-level procedures to optimize the -- position of the objects in the Dia file with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ocarina.Dia.Printer.Misc; use Ocarina.Dia.Printer.Misc; package Ocarina.Dia.Printer.Optimize is type Point_Array_Ptr is private; type Graph_Node_Record is private; type Graph_Node is access Graph_Node_Record; type Edge_Record is private; type Edge is access Edge_Record; type Compound_Graph is private; -- Translates the XML Document to a compound graph -- for optimization function XML_To_Graph (Doc : DOM.Core.Document) return Compound_Graph; -- Updates the XML Document with the new contents -- of the Graph (both must correspond) procedure Graph_To_XML (Doc : DOM.Core.Document; Graph : Compound_Graph); -- Optimization of the graph layout procedure Optimize (Graph : in out Compound_Graph); Incompatible_Arguments : exception; -- (Debug) Prints a graph to the stdo procedure Dump_Graph (G : Compound_Graph); private -- Updates a single dia:attribute procedure Update_Attribute (NL : in out DOM.Core.Node_List; Obj_Name : String; Attr_Name : String; Value : String); -- Updates an arrow's connection points procedure Update_Arrow_Points (NL : in out DOM.Core.Node_List; Value1 : String; Value2 : String); -- Updates an object's ports' positions procedure Update_Ports (NL : in out DOM.Core.Node_List; Vect : Point; Values : Point_Array_Ptr); -- Updates an object's connection points procedure Update_Connection_Points (NL : in out DOM.Core.Node_List; Vect : Point; Values : Point_Array_Ptr); -- Optimization of one Node. -- modify the input_node procedure Optimize_Node (Graph : in out Compound_Graph; I : Natural); type Point_Array is array (Integer range <>) of Point; type Point_Array_Ptr is access all Point_Array; type Edge_Record is record Dia_ID : Unbounded_String; First : Unbounded_String; First_Int : Natural; First_Port : Integer; Second : Unbounded_String; Second_Int : Natural; Second_Port : Integer; end record; type Graph_Node_Record is record ID : Natural; Dia_ID : Unbounded_String; Position : Point; Width : Float; Height : Float; BBox : Rectangle; Parent : Natural; Text : Unbounded_String; Text_Pos : Point; Ports : Point_Array_Ptr; Num_Ports : Natural; -- Not equal to Ports.Last ! because -- Ports contains connection points as well end record; type Graph_Node_Array is array (Integer range <>) of Graph_Node; type Graph_Node_Array_Ptr is access Graph_Node_Array; type Adjacent_Graph is array (Integer range <>) of Edge; type Adjacent_Graph_Ptr is access Adjacent_Graph; type Inclusion_Graph is array (Integer range <>) of Edge; type Inclusion_Graph_Ptr is access Inclusion_Graph; type Compound_Graph is record Nodes : Graph_Node_Array_Ptr; Edges : Adjacent_Graph_Ptr; Hierarchy : Inclusion_Graph_Ptr; end record; -- List of Naturals type List_Element; type List_Nat is access List_Element; type List_Element is record H : Natural; Q : List_Nat; end record; type Float_Array is array (Integer range <>) of Float; type Float_Array_Ptr is access all Float_Array; type Boolean_Array is array (Integer range <>) of Boolean; type Boolean_Array_Ptr is access all Boolean_Array; type Natural_Array is array (Integer range <>) of Natural; type Natural_Array_Ptr is access all Natural_Array; procedure Add (L : in out List_Nat; I : in Integer); -- procedure Free_List (L : in out List_Nat); function Highest (A : Float_Array) return Natural; function Max (A : Float; B : Float) return Float; procedure Remove (L : in out List_Nat; I : Integer); function Element_Index (L : List_Nat; I : Integer) return Natural; function Pow (F : Float; I : Integer) return Float; function Is_Up (P : Point; P1 : Point; P2 : Point) return Boolean; function Copy_List (L : List_Nat) return List_Nat; end Ocarina.Dia.Printer.Optimize;