Toc Gallery Index Tree Gtk.Extra.Plot_3D

Screenshot

No screeshot

Hierarchy

Description

A special plot that draws its data in three dimension. The data associated with such plots should either be a function or a Gtk.Extra.Plot_Surface.

Types

  • type Gtk_Plot_3D is access all Gtk_Plot_3D_Record'Class;
  • type Gtk_Plot_3D_Record is new Gtk.Extra.Plot.Gtk_Plot_Record with private;
  • type Plot_Plane is new Integer;
  • type Plot_Side is mod 2 ** 32;

Subprograms

  • procedure Gtk_New (Widget : out Gtk_Plot_3D; Drawable : Gdk.Drawable.Gdk_Drawable; Width, Height : Gdouble := 0.0);
    Create a new 3D plot.
  • procedure Initialize (Widget : access Gtk_Plot_3D_Record'Class; Drawable : Gdk.Drawable.Gdk_Drawable; Width, Height : Gdouble);
    Internal initialization function. See the section "Creating your own widgets" in the documentation.
  • function Get_Type return Gtk.Gtk_Type;
    Return the internal value associated with this widget.
  • procedure Autoscale (Plot : access Gtk_Plot_3D_Record);
    Chooses the best ranges for all coordinates depending on the data sets put in Plot. Note that only data sets whose points you have set explicitely are taken into account, not the ones based on functions.
  • function Get_Xfactor (Plot : access Gtk_Plot_3D_Record) return Gdouble;
    function Get_Yfactor (Plot : access Gtk_Plot_3D_Record) return Gdouble;
    function Get_Zfactor (Plot : access Gtk_Plot_3D_Record) return Gdouble;
    Get the scaling factor along each of the coordinates.
  • procedure Set_Xfactor (Plot : access Gtk_Plot_3D_Record; Xfactor : Gdouble);
    procedure Set_Yfactor (Plot : access Gtk_Plot_3D_Record; Yfactor : Gdouble);
    procedure Set_Zfactor (Plot : access Gtk_Plot_3D_Record; Zfactor : Gdouble);
    Set the scaling factor along each of the coordinates
  • procedure Set_Xrange (Plot : access Gtk_Plot_3D_Record; Min, Max : Gdouble);
    procedure Set_Yrange (Plot : access Gtk_Plot_3D_Record; Min, Max : Gdouble);
    procedure Set_Zrange (Plot : access Gtk_Plot_3D_Record; Min, Max : Gdouble);
    Set the minimal and maximal values for each axis.
  • Axis

  • procedure Show_Title (Plot : access Gtk_Plot_3D_Record; Side : Plot_Side);
    Show the title associated with the axis.
  • procedure Hide_Title (Plot : access Gtk_Plot_3D_Record; Side : Plot_Side);
    Hide the title associated with the axis.
  • procedure Set_Major_Ticks (Plot : access Gtk_Plot_3D_Record; Axis : Gtk.Extra.Plot.Plot_Orientation; Major_Step : Gdouble);
    Modify the step for major ticks. This is a percentage value that indicates how many major ticks are drawn along the axis. See also Axis_Set_Ticks.
  • procedure Set_Minor_Ticks (Plot : access Gtk_Plot_3D_Record; Axis : Gtk.Extra.Plot.Plot_Orientation; Nminor : Gint);
    Modify the number of minor ticks between each major one. See also Axis_Set_Ticks.
  • procedure Set_Ticks (Plot : access Gtk_Plot_3D_Record; Axis : Gtk.Extra.Plot.Plot_Orientation; Major_Step : Gdouble; Nminor : Gint);
    Set up ticks for a specific orientation. A horizontal orientation will match the left and right sides, whereas a vertical orientation will match the top and bottom sides. Major_Step is a percentage value of the widget size, and indicate the step between each big ticks. For instance, if Major_Step has a value of 0.2, there will be 5 big ticks drawn along the axis. Num_Minor is the number of minor ticks between each major one.
  • procedure Set_Ticks_Length (Plot : access Gtk_Plot_3D_Record; Axis : Gtk.Extra.Plot.Plot_Orientation; Length : Gint);
    Set the length (in pixels) of the big ticks. The small ticks will have half this length.
  • procedure Set_Ticks_Width (Plot : access Gtk_Plot_3D_Record; Axis : Gtk.Extra.Plot.Plot_Orientation; Width : Gfloat);
    Set the width (in pixels) of the ticks. This width is common to both the long and short ticks.
  • procedure Show_Labels (Plot : access Gtk_Plot_3D_Record; Side : Plot_Side; Label_Mask : Gint);
    Indicate whether a label should be drawn at each ticks to indicate its value. Not all values of Labels_Mask are relevant for all axis. For instance, for a vertical axis, the relevant values are Label_Right and Label_Left.
  • procedure Show_Ticks (Plot : access Gtk_Plot_3D_Record; Side : Plot_Side; Major_Mask : Gtk.Extra.Plot.Plot_Ticks_Pos; Minor_Mask : Gtk.Extra.Plot.Plot_Ticks_Pos);
    Set the style of the ticks.
  • function Get_Axis (Plot : access Gtk_Plot_3D_Record; Orientation : Gtk.Extra.Plot.Plot_Orientation) return Gtk.Extra.Plot.Gtk_Plot_Axis;
    Return a handle to a specific axis.
  • function Get_Side (Plot : access Gtk_Plot_3D_Record; Side : Plot_Side) return Gtk.Extra.Plot.Gtk_Plot_Axis;
    Get the axis for a specific side.
  • procedure Set_Scale (Plot : access Gtk_Plot_3D_Record; Axis : Gtk.Extra.Plot.Plot_Orientation; Scale : Gtk.Extra.Plot_Data.Plot_Scale);
    Set the scale for the axis
  • function Get_Scale (Plot : access Gtk_Plot_3D_Record; Axis : Gtk.Extra.Plot.Plot_Orientation) return Gtk.Extra.Plot_Data.Plot_Scale;
    Get the current sale for the axis
  • Grid

  • procedure Major_Grids_Set_Visible (Plot : access Gtk_Plot_3D_Record; X, Y, Z : Boolean);
    Indicate whether the grid should be displayed for each coordinate
  • procedure Major_Grids_Visible (Plot : access Gtk_Plot_3D_Record; X, Y, Z : out Boolean);
    Indicate whether the grid is currently displayed.
  • procedure Minor_Grids_Set_Visible (Plot : access Gtk_Plot_3D_Record; X, Y, Z : Boolean);
    Indicate whether the grid should be displayed for each coordinate
  • procedure Minor_Grids_Visible (Plot : access Gtk_Plot_3D_Record; X, Y, Z : out Boolean);
    Indicate whether the grid is currently displayed.
  • procedure Major_Zgrid_Get_Attributes (Plot : access Gtk_Plot_3D_Record; Style : out Gtk.Extra.Plot_Data.Plot_Line_Style; Width : out Gfloat; Color : out Gdk.Color.Gdk_Color);
    Get the attributes of the major grid
  • procedure Major_Zgrid_Set_Attributes (Plot : access Gtk_Plot_3D_Record; Style : Gtk.Extra.Plot_Data.Plot_Line_Style; Width : Gfloat; Color : Gdk.Color.Gdk_Color);
    Set the attributes of the major grid
  • procedure Minor_Zgrid_Get_Attributes (Plot : access Gtk_Plot_3D_Record; Style : out Gtk.Extra.Plot_Data.Plot_Line_Style; Width : out Gfloat; Color : out Gdk.Color.Gdk_Color);
    Get the attributes of the minor grid
  • procedure Minor_Zgrid_Set_Attributes (Plot : access Gtk_Plot_3D_Record; Style : Gtk.Extra.Plot_Data.Plot_Line_Style; Width : Gfloat; Color : Gdk.Color.Gdk_Color);
    Set the attributes of the minor grid
  • Rotating

  • procedure Reset_Angles (Plot : access Gtk_Plot_3D_Record);
    reset all the angles to their default values
  • procedure Rotate (Plot : access Gtk_Plot_3D_Record; Angle_X, Angle_Y, Angle_Z : Gdouble);
    Rotate the plot along the three axis at the same time. The angles are specified in degrees.
  • procedure Rotate_Vector (Plot : access Gtk_Plot_3D_Record; Vector : Gtk.Extra.Plot.Plot_Vector; A1, A2, A3 : Gdouble);
    Rotate Vector along the three axis. The three angles A1, A2 and A3 are specified in degrees.
  • procedure Rotate_X (Plot : access Gtk_Plot_3D_Record; Angle : Gdouble);
    procedure Rotate_Y (Plot : access Gtk_Plot_3D_Record; Angle : Gdouble);
    procedure Rotate_Z (Plot : access Gtk_Plot_3D_Record; Angle : Gdouble);
    Rotate the plot along a specific axis. Angle is specific in degrees.
  • Planes

    A 3D plot is associated, as usual, with three axis (one per coordinate X, Y and Z). These three axis, together, define 3 planes that can be shown or hidden, and on which a grid can be displayed to make it easy to visualize the value of the data.
  • procedure Plane_Set_Color (Plot : access Gtk_Plot_3D_Record; Plane : Plot_Plane; Color : Gdk.Color.Gdk_Color);
    Define the background color to use for one of the planes. Each plane can have its own color.
  • procedure Plane_Set_Visible (Plot : access Gtk_Plot_3D_Record; Plane : Plot_Plane; Visible : Boolean);
    Indicate whether each plane should be displayed or not.
  • function Plane_Visible (Plot : access Gtk_Plot_3D_Record; Plane : Plot_Plane) return Boolean;
    Indicate whether a plane is currently visible or not.
  • Corners

    In addition to drawing the three planes defined by the axis, a 3D plot can also draw some lines to draw a cube around the plot (although the three new planes defined by these lines are left transparent so that the plot is visible.
  • procedure Corner_Get_Attributes (Plot : access Gtk_Plot_3D_Record; Style : out Gtk.Extra.Plot_Data.Plot_Line_Style; Width : out Gfloat; Color : out Gdk.Color.Gdk_Color);
    Get the style of the corner lines.
  • procedure Corner_Set_Attributes (Plot : access Gtk_Plot_3D_Record; Style : Gtk.Extra.Plot_Data.Plot_Line_Style; Width : Gfloat; Color : Gdk.Color.Gdk_Color);
    Define the style of the corner lines.
  • procedure Corner_Set_Visible (Plot : access Gtk_Plot_3D_Record; Visible : Boolean);
    Whether corners should be visible
  • function Corner_Visible (Plot : access Gtk_Plot_3D_Record) return Boolean;
    Indicate whether corners are visible
  • Misc

  • procedure Frame_Get_Attributes (Plot : access Gtk_Plot_3D_Record; Style : out Gtk.Extra.Plot_Data.Plot_Line_Style; Width : out Gfloat; Color : out Gdk.Color.Gdk_Color);
  • procedure Frame_Set_Attributes (Plot : access Gtk_Plot_3D_Record; Style : Gtk.Extra.Plot_Data.Plot_Line_Style; Width : Gfloat; Color : Gdk.Color.Gdk_Color);
  • procedure Get_Pixel (Plot : access Gtk_Plot_3D_Record; X, Y, Z : Gdouble; Px, Py, Pz : out Gdouble);
  • function Get_Titles_Offset (Plot : access Gtk_Plot_3D_Record) return Gint;
  • procedure Set_Titles_Offset (Plot : access Gtk_Plot_3D_Record; Offset : Gint);

Signals

Testgtk source code

This code is part of testgtk, a demo application packaged with GtkAda. Testgtk demonstrates the various widgets of GtkAda
----------------------------------------------------------------------- -- GtkAda - Ada95 binding for the Gimp Toolkit -- -- -- -- Copyright (C) 2000 -- -- Emmanuel Briot, Joel Brobecker and Arnaud Charlet -- -- Copyright (C) 2003-2006 AdaCore -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU General Public -- -- License as published by the Free Software Foundation; either -- -- version 2 of the License, or (at your option) any later version. -- -- -- -- This library 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 along with this library; if not, write to the -- -- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- -- Boston, MA 02111-1307, USA. -- -- -- -- -- -- -- -- -- -- ----------------------------------------------------------------------- with Glib; use Glib; with Gtk.Box; use Gtk.Box; with Gtk.Button; use Gtk.Button; with Gtk.Enums; use Gtk.Enums; with Gtk.Extra.Plot; use Gtk.Extra.Plot; with Gtk.Extra.Plot_Data; use Gtk.Extra.Plot_Data; with Gtk.Extra.Plot_Canvas; use Gtk.Extra.Plot_Canvas; with Gtk.Extra.Plot_Canvas.Plot; use Gtk.Extra.Plot_Canvas.Plot; with Gtk.Extra.Plot_3D; use Gtk.Extra.Plot_3D; with Gtk.Extra.Plot_Surface; use Gtk.Extra.Plot_Surface; with Gtk.Frame; use Gtk.Frame; with Gtk.Scrolled_Window; use Gtk.Scrolled_Window; with Gtk.Handlers; use Gtk.Handlers; with Ada.Numerics.Generic_Elementary_Functions; with System; package body Create_Plot_3D is package Layout_Cb is new Gtk.Handlers.Callback (Gtk_Plot_Canvas_Record); package Double_Numerics is new Ada.Numerics.Generic_Elementary_Functions (Gdouble); use Double_Numerics; procedure Rotatex (Canvas : access Gtk_Plot_Canvas_Record'Class); procedure Rotatey (Canvas : access Gtk_Plot_Canvas_Record'Class); procedure Rotatez (Canvas : access Gtk_Plot_Canvas_Record'Class); -- rotates the plot in one of the usual directions function My_Function (Plot : System.Address; Set : Gtk_Plot_Data; X, Y : Gdouble; Error : access Gboolean) return Gdouble; pragma Convention (C, My_Function); Active_Plot : Gtk_Plot_3D; ----------------- -- My_Function -- ----------------- function My_Function (Plot : System.Address; Set : Gtk_Plot_Data; X, Y : Gdouble; Error : access Gboolean) return Gdouble is pragma Warnings (Off, Plot); pragma Warnings (Off, Set); begin Error.all := 0; return Cos (((X - 0.5) * (X - 0.5) + (Y - 0.5) *(Y - 0.5)) * 24.0) / 4.0 + 0.5; end My_Function; ------------- -- Rotatex -- ------------- procedure Rotatex (Canvas : access Gtk_Plot_Canvas_Record'Class) is begin Rotate_X (Active_Plot, 10.0); Paint (Canvas); Refresh (Canvas); end Rotatex; ------------- -- Rotatey -- ------------- procedure Rotatey (Canvas : access Gtk_Plot_Canvas_Record'Class) is begin Rotate_Y (Active_Plot, 10.0); Paint (Canvas); Refresh (Canvas); end Rotatey; ------------- -- Rotatez -- ------------- procedure Rotatez (Canvas : access Gtk_Plot_Canvas_Record'Class) is begin Rotate_Z (Active_Plot, 10.0); Paint (Canvas); Refresh (Canvas); end Rotatez; ---------- -- Help -- ---------- function Help return String is begin return "See the @bPlot demo@B for more information"; end Help; --------- -- Run -- --------- procedure Run (Frame : access Gtk.Frame.Gtk_Frame_Record'Class) is Vbox1 : Gtk_Box; Scrollw1 : Gtk_Scrolled_Window; Button : Gtk_Button; Plot : Gtk_Plot_3D; Canvas : Gtk_Plot_Canvas; Surface : Gtk_Plot_Surface; Plot_Child : Gtk_Plot_Canvas_Plot; begin Set_Label (Frame, "Gtk.Extra.Plot_3D demo"); Gtk_New_Vbox (Vbox1, False, 0); Add (Frame, Vbox1); -- Put the Plot in a scrolled window, in case it is too big for -- the screen Gtk_New (Scrollw1); Set_Border_Width (Scrollw1, 0); Set_Policy (Scrollw1, Policy_Always, Policy_Always); Pack_Start (Vbox1, Scrollw1, True, True, 0); -- Create the canvas in which the plot will be drawn Gtk_New (Canvas, Gint (Get_Allocation_Width (Frame) - 10), Gint (Get_Allocation_Height (Frame) - 10), 1.0); Plot_Canvas_Set_Flags (Canvas, Dnd_Flags); Add_With_Viewport (Scrollw1, Canvas); -- Create the plot Gtk_New (Plot, null, 0.7, 0.7); Gtk_New (Plot_Child, Plot); Put_Child (Canvas, Plot_Child, 0.1, 0.06, 0.9, 0.9); Show (Plot); Active_Plot := Plot; Set_Minor_Ticks (Plot, Axis_X, 1); Set_Minor_Ticks (Plot, Axis_Y, 1); Show_Ticks (Plot, Plot_Side_Xy, Ticks_Out, Ticks_Out); Show_Ticks (Plot, Plot_Side_Xz, Ticks_Out, Ticks_Out); Show_Ticks (Plot, Plot_Side_Yz, Ticks_Out, Ticks_Out); Corner_Set_Visible (Plot, True); -- Create the data set Gtk_New (Surface, My_Function'Access); Set_Xstep (Surface, 0.025); Set_Ystep (Surface, 0.025); Set_Legend (Surface, "cos ((r-r\s0\N)\S2\N)"); Add_Data (Plot, Surface); Show (Surface); -- Buttons Gtk_New (Button, "Rotate X"); Put (Canvas, Button, 80, 0); Layout_Cb.Object_Connect (Button, "clicked", Layout_Cb.To_Marshaller (Rotatex'Access), Canvas); Gtk_New (Button, "Rotate Y"); Put (Canvas, Button, 160, 0); Layout_Cb.Object_Connect (Button, "clicked", Layout_Cb.To_Marshaller (Rotatey'Access), Canvas); Gtk_New (Button, "Rotate Z"); Put (Canvas, Button, 240, 0); Layout_Cb.Object_Connect (Button, "clicked", Layout_Cb.To_Marshaller (Rotatez'Access), Canvas); Show_All (Frame); end Run; end Create_Plot_3D;

Alphabetical Index