1. ----------------------------------------------------------------------- 
  2. --              GtkAda - Ada95 binding for Gtk+/Gnome                -- 
  3. --                                                                   -- 
  4. --                     Copyright (C) 2001-2006                       -- 
  5. --                         AdaCore                                   -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- -- -- -- -- -- -- -- -- -- -- --
  23. ----------------------------------------------------------------------- 
  24.  
  25. --  <description> 
  26. --  A special plot that draws its data in three dimension. The data associated 
  27. --  with such plots should either be a function or a Gtk.Extra.Plot_Surface. 
  28. --  </description> 
  29. --  <c_version>gtkextra 2.1.1</c_version> 
  30. --  <group>Plotting Data</group> 
  31. --  <testgtk>create_plot_3d.adb</testgtk> 
  32. --  <screenshot>gtk-plot_3d</screenshot> 
  33.  
  34. with Gdk.Color; 
  35. with Gdk.Drawable; 
  36. with Gtk.Extra.Plot; 
  37. with Gtk.Extra.Plot_Data; 
  38.  
  39. package Gtk.Extra.Plot_3D is 
  40.  
  41.    type Gtk_Plot_3D_Record is new Gtk.Extra.Plot.Gtk_Plot_Record with private; 
  42.    type Gtk_Plot_3D is access all Gtk_Plot_3D_Record'Class; 
  43.  
  44.    type Plot_Plane is new Integer; 
  45.    Plot_Plane_Xy : constant Plot_Plane := 0; 
  46.    Plot_Plane_Yx : constant Plot_Plane := 0; 
  47.    Plot_Plane_Xz : constant Plot_Plane := 1; 
  48.    Plot_Plane_Zx : constant Plot_Plane := 1; 
  49.    Plot_Plane_Yz : constant Plot_Plane := 2; 
  50.    Plot_Plane_Zy : constant Plot_Plane := 2; 
  51.  
  52.    type Plot_Side is mod 2 ** 32; 
  53.    Plot_Side_Xy : constant Plot_Side := 2 ** 0; 
  54.    Plot_Side_Xz : constant Plot_Side := 2 ** 1; 
  55.    Plot_Side_Yx : constant Plot_Side := 2 ** 2; 
  56.    Plot_Side_Yz : constant Plot_Side := 2 ** 3; 
  57.    Plot_Side_Zx : constant Plot_Side := 2 ** 4; 
  58.    Plot_Side_Zy : constant Plot_Side := 2 ** 5; 
  59.  
  60.    procedure Gtk_New 
  61.      (Widget        : out Gtk_Plot_3D; 
  62.       Drawable      : Gdk.Drawable.Gdk_Drawable; 
  63.       Width, Height : Gdouble := 0.0); 
  64.    --  Create a new 3D plot. 
  65.  
  66.    procedure Initialize 
  67.      (Widget        : access Gtk_Plot_3D_Record'Class; 
  68.       Drawable      : Gdk.Drawable.Gdk_Drawable; 
  69.       Width, Height : Gdouble); 
  70.    --  Internal initialization function. 
  71.    --  See the section "Creating your own widgets" in the documentation. 
  72.  
  73.    function Get_Type return Gtk.Gtk_Type; 
  74.    --  Return the internal value associated with this widget. 
  75.  
  76.    procedure Autoscale (Plot : access Gtk_Plot_3D_Record); 
  77.    --  Chooses the best ranges for all coordinates depending on the data sets 
  78.    --  put in Plot. Note that only data sets whose points you have set 
  79.    --  explicitely are taken into account, not the ones based on functions. 
  80.  
  81.    function Get_Xfactor (Plot : access Gtk_Plot_3D_Record) return Gdouble; 
  82.    function Get_Yfactor (Plot : access Gtk_Plot_3D_Record) return Gdouble; 
  83.    function Get_Zfactor (Plot : access Gtk_Plot_3D_Record) return Gdouble; 
  84.    --  Get the scaling factor along each of the coordinates. 
  85.  
  86.    procedure Set_Xfactor (Plot : access Gtk_Plot_3D_Record; Xfactor : Gdouble); 
  87.    procedure Set_Yfactor (Plot : access Gtk_Plot_3D_Record; Yfactor : Gdouble); 
  88.    procedure Set_Zfactor (Plot : access Gtk_Plot_3D_Record; Zfactor : Gdouble); 
  89.    --  Set the scaling factor along each of the coordinates 
  90.  
  91.    procedure Set_Xrange (Plot : access Gtk_Plot_3D_Record; Min, Max : Gdouble); 
  92.    procedure Set_Yrange (Plot : access Gtk_Plot_3D_Record; Min, Max : Gdouble); 
  93.    procedure Set_Zrange (Plot : access Gtk_Plot_3D_Record; Min, Max : Gdouble); 
  94.    --  Set the minimal and maximal values for each axis. 
  95.  
  96.    ---------- 
  97.    -- Axis -- 
  98.    ---------- 
  99.  
  100.    procedure Show_Title 
  101.      (Plot : access Gtk_Plot_3D_Record; Side : Plot_Side); 
  102.    --  Show the title associated with the axis. 
  103.  
  104.    procedure Hide_Title 
  105.      (Plot : access Gtk_Plot_3D_Record; Side : Plot_Side); 
  106.    --  Hide the title associated with the axis. 
  107.  
  108.    procedure Set_Major_Ticks 
  109.      (Plot       : access Gtk_Plot_3D_Record; 
  110.       Axis       : Gtk.Extra.Plot.Plot_Orientation; 
  111.       Major_Step : Gdouble); 
  112.    --  Modify the step for major ticks. 
  113.    --  This is a percentage value that indicates how many major ticks are 
  114.    --  drawn along the axis. See also Axis_Set_Ticks. 
  115.  
  116.    procedure Set_Minor_Ticks 
  117.      (Plot   : access Gtk_Plot_3D_Record; 
  118.       Axis   : Gtk.Extra.Plot.Plot_Orientation; 
  119.       Nminor : Gint); 
  120.    --  Modify the number of minor ticks between each major one. 
  121.    --  See also Axis_Set_Ticks. 
  122.  
  123.    procedure Set_Ticks 
  124.      (Plot       : access Gtk_Plot_3D_Record; 
  125.       Axis       : Gtk.Extra.Plot.Plot_Orientation; 
  126.       Major_Step : Gdouble; 
  127.       Nminor     : Gint); 
  128.    --  Set up ticks for a specific orientation. 
  129.    --  A horizontal orientation will match the left and right sides, whereas 
  130.    --  a vertical orientation will match the top and bottom sides. 
  131.    --  Major_Step is a percentage value of the widget size, and indicate the 
  132.    --  step between each big ticks. For instance, if Major_Step has a value 
  133.    --  of 0.2, there will be 5 big ticks drawn along the axis. 
  134.    --  Num_Minor is the number of minor ticks between each major one. 
  135.  
  136.    procedure Set_Ticks_Length 
  137.      (Plot   : access Gtk_Plot_3D_Record; 
  138.       Axis   : Gtk.Extra.Plot.Plot_Orientation; 
  139.       Length : Gint); 
  140.    --  Set the length (in pixels) of the big ticks. 
  141.    --  The small ticks will have half this length. 
  142.  
  143.    procedure Set_Ticks_Width 
  144.      (Plot  : access Gtk_Plot_3D_Record; 
  145.       Axis  : Gtk.Extra.Plot.Plot_Orientation; 
  146.       Width : Gfloat); 
  147.    --  Set the width (in pixels) of the ticks. 
  148.    --  This width is common to both the long and short ticks. 
  149.  
  150.    procedure Show_Labels 
  151.      (Plot       : access Gtk_Plot_3D_Record; 
  152.       Side       : Plot_Side; 
  153.       Label_Mask : Gint); 
  154.    --  Indicate whether a label should be drawn at each ticks to indicate 
  155.    --  its value. 
  156.    --  Not all values of Labels_Mask are relevant for all axis. For instance, 
  157.    --  for a vertical axis, the relevant values are Label_Right and Label_Left. 
  158.  
  159.    procedure Show_Ticks 
  160.      (Plot       : access Gtk_Plot_3D_Record; 
  161.       Side       : Plot_Side; 
  162.       Major_Mask : Gtk.Extra.Plot.Plot_Ticks_Pos; 
  163.       Minor_Mask : Gtk.Extra.Plot.Plot_Ticks_Pos); 
  164.    --  Set the style of the ticks. 
  165.  
  166.    function Get_Axis 
  167.      (Plot        : access Gtk_Plot_3D_Record; 
  168.       Orientation : Gtk.Extra.Plot.Plot_Orientation) 
  169.       return Gtk.Extra.Plot.Gtk_Plot_Axis; 
  170.    --  Return a handle to a specific axis. 
  171.  
  172.    function Get_Side 
  173.      (Plot : access Gtk_Plot_3D_Record; Side : Plot_Side) 
  174.       return Gtk.Extra.Plot.Gtk_Plot_Axis; 
  175.    --  Get the axis for a specific side. 
  176.  
  177.    procedure Set_Scale 
  178.      (Plot  : access Gtk_Plot_3D_Record; 
  179.       Axis  : Gtk.Extra.Plot.Plot_Orientation; 
  180.       Scale : Gtk.Extra.Plot_Data.Plot_Scale); 
  181.    --  Set the scale for the axis 
  182.  
  183.    function Get_Scale 
  184.      (Plot  : access Gtk_Plot_3D_Record; 
  185.       Axis  : Gtk.Extra.Plot.Plot_Orientation) 
  186.       return Gtk.Extra.Plot_Data.Plot_Scale; 
  187.    --  Get the current sale for the axis 
  188.  
  189.    ---------- 
  190.    -- Grid -- 
  191.    ---------- 
  192.  
  193.    procedure Major_Grids_Set_Visible 
  194.      (Plot : access Gtk_Plot_3D_Record; X, Y, Z : Boolean); 
  195.    --  Indicate whether the grid should be displayed for each coordinate 
  196.  
  197.    procedure Major_Grids_Visible 
  198.      (Plot : access Gtk_Plot_3D_Record; X, Y, Z : out Boolean); 
  199.    --  Indicate whether the grid is currently displayed. 
  200.  
  201.    procedure Minor_Grids_Set_Visible 
  202.      (Plot : access Gtk_Plot_3D_Record; X, Y, Z : Boolean); 
  203.    --  Indicate whether the grid should be displayed for each coordinate 
  204.  
  205.    procedure Minor_Grids_Visible 
  206.      (Plot : access Gtk_Plot_3D_Record; X, Y, Z : out Boolean); 
  207.    --  Indicate whether the grid is currently displayed. 
  208.  
  209.    procedure Major_Zgrid_Get_Attributes 
  210.      (Plot  : access Gtk_Plot_3D_Record; 
  211.       Style : out Gtk.Extra.Plot_Data.Plot_Line_Style; 
  212.       Width : out Gfloat; 
  213.       Color : out Gdk.Color.Gdk_Color); 
  214.    --  Get the attributes of the major grid 
  215.  
  216.    procedure Major_Zgrid_Set_Attributes 
  217.      (Plot  : access Gtk_Plot_3D_Record; 
  218.       Style : Gtk.Extra.Plot_Data.Plot_Line_Style; 
  219.       Width : Gfloat; 
  220.       Color : Gdk.Color.Gdk_Color); 
  221.    --  Set the attributes of the major grid 
  222.  
  223.    procedure Minor_Zgrid_Get_Attributes 
  224.      (Plot  : access Gtk_Plot_3D_Record; 
  225.       Style : out Gtk.Extra.Plot_Data.Plot_Line_Style; 
  226.       Width : out Gfloat; 
  227.       Color : out Gdk.Color.Gdk_Color); 
  228.    --  Get the attributes of the minor grid 
  229.  
  230.    procedure Minor_Zgrid_Set_Attributes 
  231.      (Plot  : access Gtk_Plot_3D_Record; 
  232.       Style : Gtk.Extra.Plot_Data.Plot_Line_Style; 
  233.       Width : Gfloat; 
  234.       Color : Gdk.Color.Gdk_Color); 
  235.    --  Set the attributes of the minor grid 
  236.  
  237.    -------------- 
  238.    -- Rotating -- 
  239.    -------------- 
  240.  
  241.    procedure Reset_Angles (Plot : access Gtk_Plot_3D_Record); 
  242.    --  reset all the angles to their default values 
  243.  
  244.    procedure Rotate 
  245.      (Plot    : access Gtk_Plot_3D_Record; 
  246.       Angle_X, Angle_Y, Angle_Z : Gdouble); 
  247.    --  Rotate the plot along the three axis at the same time. 
  248.    --  The angles are specified in degrees. 
  249.  
  250.    procedure Rotate_Vector 
  251.      (Plot       : access Gtk_Plot_3D_Record; 
  252.       Vector     : Gtk.Extra.Plot.Plot_Vector; 
  253.       A1, A2, A3 : Gdouble); 
  254.    --  Rotate Vector along the three axis. 
  255.    --  The three angles A1, A2 and A3 are specified in degrees. 
  256.  
  257.    procedure Rotate_X (Plot  : access Gtk_Plot_3D_Record; Angle : Gdouble); 
  258.    procedure Rotate_Y (Plot  : access Gtk_Plot_3D_Record; Angle : Gdouble); 
  259.    procedure Rotate_Z (Plot  : access Gtk_Plot_3D_Record; Angle : Gdouble); 
  260.    --  Rotate the plot along a specific axis. 
  261.    --  Angle is specific in degrees. 
  262.  
  263.    ------------ 
  264.    -- Planes -- 
  265.    ------------ 
  266.    --  A 3D plot is associated, as usual, with three axis (one per coordinate 
  267.    --  X, Y and Z). These three axis, together, define 3 planes that can be 
  268.    --  shown or hidden, and on which a grid can be displayed to make it easy 
  269.    --  to visualize the value of the data. 
  270.  
  271.    procedure Plane_Set_Color 
  272.      (Plot : access Gtk_Plot_3D_Record; 
  273.       Plane : Plot_Plane; 
  274.       Color : Gdk.Color.Gdk_Color); 
  275.    --  Define the background color to use for one of the planes. Each plane 
  276.    --  can have its own color. 
  277.  
  278.    procedure Plane_Set_Visible 
  279.      (Plot : access Gtk_Plot_3D_Record; Plane : Plot_Plane; Visible : Boolean); 
  280.    --  Indicate whether each plane should be displayed or not. 
  281.  
  282.    function Plane_Visible 
  283.      (Plot : access Gtk_Plot_3D_Record; Plane : Plot_Plane) return Boolean; 
  284.    --  Indicate whether a plane is currently visible or not. 
  285.  
  286.    ------------- 
  287.    -- Corners -- 
  288.    ------------- 
  289.    --  In addition to drawing the three planes defined by the axis, a 3D plot 
  290.    --  can also draw some lines to draw a cube around the plot (although the 
  291.    --  three new planes defined by these lines are left transparent so that 
  292.    --  the plot is visible. 
  293.  
  294.    procedure Corner_Get_Attributes 
  295.      (Plot  : access Gtk_Plot_3D_Record; 
  296.       Style : out Gtk.Extra.Plot_Data.Plot_Line_Style; 
  297.       Width : out Gfloat; 
  298.       Color : out Gdk.Color.Gdk_Color); 
  299.    --  Get the style of the corner lines. 
  300.  
  301.    procedure Corner_Set_Attributes 
  302.      (Plot  : access Gtk_Plot_3D_Record; 
  303.       Style : Gtk.Extra.Plot_Data.Plot_Line_Style; 
  304.       Width : Gfloat; 
  305.       Color : Gdk.Color.Gdk_Color); 
  306.    --  Define the style of the corner lines. 
  307.  
  308.    procedure Corner_Set_Visible 
  309.      (Plot : access Gtk_Plot_3D_Record; Visible : Boolean); 
  310.    --  Whether corners should be visible 
  311.  
  312.    function Corner_Visible (Plot : access Gtk_Plot_3D_Record) return Boolean; 
  313.    --  Indicate whether corners are visible 
  314.  
  315.    ---------- 
  316.    -- Misc -- 
  317.    ---------- 
  318.  
  319.    procedure Frame_Get_Attributes 
  320.      (Plot  : access Gtk_Plot_3D_Record; 
  321.       Style : out Gtk.Extra.Plot_Data.Plot_Line_Style; 
  322.       Width : out Gfloat; 
  323.       Color : out Gdk.Color.Gdk_Color); 
  324.  
  325.    procedure Frame_Set_Attributes 
  326.      (Plot  : access Gtk_Plot_3D_Record; 
  327.       Style : Gtk.Extra.Plot_Data.Plot_Line_Style; 
  328.       Width : Gfloat; 
  329.       Color : Gdk.Color.Gdk_Color); 
  330.  
  331.    procedure Get_Pixel 
  332.      (Plot       : access Gtk_Plot_3D_Record; 
  333.       X, Y, Z    : Gdouble; 
  334.       Px, Py, Pz : out Gdouble); 
  335.  
  336.    function Get_Titles_Offset (Plot : access Gtk_Plot_3D_Record) return Gint; 
  337.  
  338.    procedure Set_Titles_Offset 
  339.      (Plot : access Gtk_Plot_3D_Record; Offset : Gint); 
  340.  
  341.    ------------- 
  342.    -- Signals -- 
  343.    ------------- 
  344.  
  345.    --  <signals> 
  346.    --  The following new signals are defined for this widget: 
  347.    --  </signals> 
  348.  
  349. private 
  350.    type Gtk_Plot_3D_Record is new Gtk.Extra.Plot.Gtk_Plot_Record 
  351.      with null record; 
  352.    pragma Import (C, Get_Type, "gtk_plot3d_get_type"); 
  353. end Gtk.Extra.Plot_3D;