agpl_1.0.0_b5da3320/src/agpl-drawing-figures.ads

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
with Ada.Containers.Doubly_Linked_Lists;
with Ada.Numerics.Real_Arrays;

with Agpl.Drawing.Buffer;

package Agpl.Drawing.Figures is

   pragma Preelaborate;

   package RA renames Ada.Numerics.Real_Arrays;

   subtype Confidence is Float range 0.0 .. 1.0;

   function Null_Figure return Drawable'Class;

   type Vprogress is new Drawable with record
      X, Y,
      Width,
      Height,
      Max,
      Val        : Float;
      Text_Above : Boolean := True;
      Show_Pct   : Boolean := True;
   end record;
   procedure Draw (This : Vprogress; Into : in out Drawer'Class);

   function Segment (X1, Y1, X2, Y2 : Float) return Buffer.Object;

   function Target (X, Y : Float; Size : Float := 1.0) return Buffer.Object;
   --  A big X is marking the treasure

   function Text (X, Y : Float; S : String) return Drawable'Class;

   type Bivariate_Ellipse (<>) is new Drawable with private;
   procedure Draw (This : Bivariate_Ellipse; Into : in out Drawer'Class);

   subtype Point is Ra.Real_Vector (1 .. 2);
   subtype Cov2d is Ra.Real_Matrix (1 .. 2, 1 .. 2);

   function Create_Bivariate_Ellipse
     (Mu     : Point;              -- Mean of distribution.
      Th     : Float;              -- Angle of whatever this Mu corresponds.
      Sigma  : Cov2d;              --  Covariance of distro.
                                   --  This is a symmetric positive semi-definite matrix.
      Conf   : Confidence := 0.95; -- Percent of probability mass inside the ellipse
      Curve  : Boolean := True;    -- Draw ellipse
      Axes   : Boolean := True;    -- Draw axes
      Points : Positive := 20      -- Points to approximate ellipse
     ) return Bivariate_Ellipse;
   --  Adapted from
   --  http://openslam.informatik.uni-freiburg.de/data/svn/tjtf/trunk/matlab/plotcov2.m

   function Robot (X, Y, A : Float;
                   Size    : Float := 0.5) return Drawable'Class;

   type Float_Array is array (Positive range <>) of Float;

   function Simple_History (Values   : Float_Array)
                            return     Drawing.Buffer.Object;
   --  Each sample is 1.0 units width

   package Float_Lists is new Ada.Containers.Doubly_Linked_Lists (Float);
   type Float_List is new Float_Lists.List with null record;

   procedure Add_Sample (List : in out Float_List; Sample : Float);
   procedure Trim (List : in out Float_List; Samples : Natural);
   --  Remove excess List.First_Element (i.e. new samples go to tail)

   function Simple_History (Values   : Float_List)
                            return     Drawing.Buffer.Object;
   --  Each sample is 1.0 units width

   function Simple_History (Min, Max : Float;
                            Values   : Float_List;
                            Max_Vals : Natural;
                            Val_RGB  : Types.Rgb_Triplet := (0, 0, 255);
                            Axis_RGB : Types.Rgb_triplet := (0, 0, 0))
                            return     Drawing.Buffer.object;
   --  As above, but all-in-one.
   --  Max vals is used to make the rangespan in the axis

private

   type Bivariate_Ellipse is new Drawable with record
      Mu     : Point;
      Th     : Float;
      Sigma  : Cov2d;
      Conf   : Confidence;
      Curve  : Boolean;
      Axes   : Boolean;
      Points : Positive;
   end record;

end Agpl.Drawing.Figures;