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