---------------------------------------------- ---------------------------------- -- -- -- 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;