File: gtk-extra-plot_surface.adb

package info (click to toggle)
libgtkada2 2.8.1-6lenny3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 13,496 kB
  • ctags: 3,886
  • sloc: ada: 103,189; ansic: 45,411; perl: 5,500; sh: 2,812; makefile: 1,169; xml: 19
file content (472 lines) | stat: -rw-r--r-- 15,134 bytes parent folder | download | duplicates (2)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
-----------------------------------------------------------------------
--              GtkAda - Ada95 binding for Gtk+/Gnome                --
--                                                                   --
--                     Copyright (C) 2001-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 System;

with Gdk.Color;              use Gdk.Color;
with Gtk.Extra.Plot;         use Gtk.Extra.Plot;

package body Gtk.Extra.Plot_Surface is

   -------------
   -- Gtk_New --
   -------------

   procedure Gtk_New
     (Widget : out Gtk_Plot_Surface; Func : Plot3D_Function := null) is
   begin
      Widget := new Gtk_Plot_Surface_Record;
      Initialize (Widget, Func);
   end Gtk_New;

   ----------------
   -- Initialize --
   ----------------

   procedure Initialize
     (Widget : access Gtk_Plot_Surface_Record'Class;
      Func : Plot3D_Function := null)
   is
      function Internal return System.Address;
      pragma Import (C, Internal, "gtk_plot_surface_new");

      function Internal2 (Func : Plot3D_Function) return System.Address;
      pragma Import (C, Internal2, "gtk_plot_surface_new_function");
   begin
      if Func = null then
         Set_Object (Widget, Internal);
      else
         Set_Object (Widget, Internal2 (Func));
      end if;
   end Initialize;

   ----------------------
   -- Get_Grid_Visible --
   ----------------------

   function Get_Grid_Visible
     (Data : access Gtk_Plot_Surface_Record) return Boolean
   is
      function Internal (Data : System.Address) return Gint;
      pragma Import (C, Internal, "gtk_plot_surface_get_grid_visible");
   begin
      return Boolean'Val (Internal (Get_Object (Data)));
   end Get_Grid_Visible;

   ----------------------
   -- Get_Mesh_Visible --
   ----------------------

   function Get_Mesh_Visible
     (Data : access Gtk_Plot_Surface_Record) return Boolean
   is
      function Internal (Data : System.Address) return Gint;
      pragma Import (C, Internal, "gtk_plot_surface_get_mesh_visible");
   begin
      return Boolean'Val (Internal (Get_Object (Data)));
   end Get_Mesh_Visible;

   ------------
   -- Get_Nx --
   ------------

   function Get_Nx (Data : access Gtk_Plot_Surface_Record) return Gint is
      function Internal (Data   : System.Address) return Gint;
      pragma Import (C, Internal, "gtk_plot_surface_get_nx");
   begin
      return Internal (Get_Object (Data));
   end Get_Nx;

   ------------
   -- Get_Ny --
   ------------

   function Get_Ny (Data : access Gtk_Plot_Surface_Record) return Gint is
      function Internal (Data   : System.Address) return Gint;
      pragma Import (C, Internal, "gtk_plot_surface_get_ny");
   begin
      return Internal (Get_Object (Data));
   end Get_Ny;

   ----------------
   -- Get_Points --
   ----------------

   procedure Get_Points
     (Data : access Gtk_Plot_Surface_Record;
      X    : out Points_Array;
      Y    : out Points_Array;
      Z    : out Points_Array;
      Dx   : out Points_Array;
      Dy   : out Points_Array;
      Dz   : out Points_Array)
   is
      procedure Internal
        (Data : System.Address;
         X    : out System.Address;
         Y    : out System.Address;
         Z    : out System.Address;
         Dx   : out System.Address;
         Dy   : out System.Address;
         Dz   : out System.Address;
         Nx   : out Gint;
         Ny   : out Gint);
      pragma Import (C, Internal, "gtk_plot_surface_get_points");
      Nx, Ny : Gint;
      X1, Y1, Z1, Dx1, Dy1, Dz1 : System.Address;
   begin
      Internal (Get_Object (Data), X1, Y1, Z1, Dx1, Dy1, Dz1, Nx, Ny);
      X  := (Points => To_Double_Array (X1),  Num_Points => Nx);
      Y  := (Points => To_Double_Array (Y1),  Num_Points => Ny);
      Z  := (Points => To_Double_Array (Z1),  Num_Points => Nx * Ny);
      Dx := (Points => To_Double_Array (Dx1), Num_Points => Nx);
      Dy := (Points => To_Double_Array (Dy1), Num_Points => Ny);
      Dz := (Points => To_Double_Array (Dy1), Num_Points => Nx * Ny);
   end Get_Points;

   -----------
   -- Get_X --
   -----------

   function Get_X (Data : access Gtk_Plot_Surface_Record) return Points_Array
   is
      function Internal (Data : System.Address; Nx : System.Address)
         return System.Address;
      pragma Import (C, Internal, "gtk_plot_surface_get_x");
      N : aliased Gint;
      X : constant System.Address := Internal (Get_Object (Data), N'Address);

   begin
      return (To_Double_Array (X), N);
   end Get_X;

   ---------------
   -- Get_Xstep --
   ---------------

   function Get_Xstep (Data : access Gtk_Plot_Surface_Record) return Gdouble is
      function Internal (Data   : System.Address) return Gdouble;
      pragma Import (C, Internal, "gtk_plot_surface_get_xstep");
   begin
      return Internal (Get_Object (Data));
   end Get_Xstep;

   -----------
   -- Get_Y --
   -----------

   function Get_Y
     (Data : access Gtk_Plot_Surface_Record) return Points_Array
   is
      function Internal
        (Data : System.Address; Ny : System.Address) return System.Address;
      pragma Import (C, Internal, "gtk_plot_surface_get_y");

      N : aliased Gint;
      Y : constant System.Address := Internal (Get_Object (Data), N'Address);

   begin
      return (To_Double_Array (Y), N);
   end Get_Y;

   ---------------
   -- Get_Ystep --
   ---------------

   function Get_Ystep (Data : access Gtk_Plot_Surface_Record) return Gdouble
   is
      function Internal (Data : System.Address) return Gdouble;
      pragma Import (C, Internal, "gtk_plot_surface_get_ystep");
   begin
      return Internal (Get_Object (Data));
   end Get_Ystep;

   -----------
   -- Get_Z --
   -----------

   function Get_Z (Data : access Gtk_Plot_Surface_Record) return Points_Array
   is
      function Internal (Data : System.Address; Nz : System.Address)
         return System.Address;
      pragma Import (C, Internal, "gtk_plot_surface_get_z");
      N : aliased Gint;
      Z : constant System.Address := Internal (Get_Object (Data), N'Address);

   begin
      return (To_Double_Array (Z), N);
   end Get_Z;

   -----------------
   -- Set_Ambient --
   -----------------

   procedure Set_Ambient
     (Data : access Gtk_Plot_Surface_Record; Ambient : Gdouble)
   is
      procedure Internal (Data : System.Address; Ambient : Gdouble);
      pragma Import (C, Internal, "gtk_plot_surface_set_ambient");
   begin
      Internal (Get_Object (Data), Ambient);
   end Set_Ambient;

   ---------------
   -- Set_Color --
   ---------------

   procedure Set_Color
     (Data  : access Gtk_Plot_Surface_Record; Color : Gdk.Color.Gdk_Color)
   is
      procedure Internal (Data  : System.Address; Color : System.Address);
      pragma Import (C, Internal, "gtk_plot_surface_set_color");
      C : aliased Gdk_Color := Color;
   begin
      Internal (Get_Object (Data), C'Address);
   end Set_Color;

   -------------------------
   -- Set_Grid_Background --
   -------------------------

   procedure Set_Grid_Background
     (Data       : access Gtk_Plot_Surface_Record;
      Background : Gdk.Color.Gdk_Color)
   is
      procedure Internal (Data : System.Address; Background : System.Address);
      pragma Import (C, Internal, "gtk_plot_surface_set_grid_background");
      C : aliased Gdk_Color := Background;
   begin
      Internal (Get_Object (Data), C'Address);
   end Set_Grid_Background;

   -------------------------
   -- Set_Grid_Foreground --
   -------------------------

   procedure Set_Grid_Foreground
     (Data       : access Gtk_Plot_Surface_Record;
      Foreground : Gdk.Color.Gdk_Color)
   is
      procedure Internal (Data : System.Address; Foreground : System.Address);
      pragma Import (C, Internal, "gtk_plot_surface_set_grid_foreground");
      C : aliased Gdk_Color := Foreground;
   begin
      Internal (Get_Object (Data), C'Address);
   end Set_Grid_Foreground;

   ----------------------
   -- Set_Grid_Visible --
   ----------------------

   procedure Set_Grid_Visible
     (Data : access Gtk_Plot_Surface_Record; Visible : Boolean)
   is
      procedure Internal (Data : System.Address; Visible : Gint);
      pragma Import (C, Internal, "gtk_plot_surface_set_grid_visible");
   begin
      Internal (Get_Object (Data), Boolean'Pos (Visible));
   end Set_Grid_Visible;

   ---------------
   -- Set_Light --
   ---------------

   procedure Set_Light
     (Data : access Gtk_Plot_Surface_Record; X, Y, Z : Gdouble)
   is
      procedure Internal (Data : System.Address; X, Y, Z : Gdouble);
      pragma Import (C, Internal, "gtk_plot_surface_set_light");
   begin
      Internal (Get_Object (Data), X, Y, Z);
   end Set_Light;

   ----------------------
   -- Set_Mesh_Visible --
   ----------------------

   procedure Set_Mesh_Visible
     (Data : access Gtk_Plot_Surface_Record; Visible : Boolean)
   is
      procedure Internal (Data    : System.Address; Visible : Gint);
      pragma Import (C, Internal, "gtk_plot_surface_set_mesh_visible");
   begin
      Internal (Get_Object (Data), Boolean'Pos (Visible));
   end Set_Mesh_Visible;

   ------------
   -- Set_Nx --
   ------------

   procedure Set_Nx (Data : access Gtk_Plot_Surface_Record; Nx : Gint) is
      procedure Internal (Data : System.Address; Nx   : Gint);
      pragma Import (C, Internal, "gtk_plot_surface_set_nx");
   begin
      Internal (Get_Object (Data), Nx);
   end Set_Nx;

   ------------
   -- Set_Ny --
   ------------

   procedure Set_Ny (Data : access Gtk_Plot_Surface_Record; Ny : Gint) is
      procedure Internal (Data : System.Address; Ny   : Gint);
      pragma Import (C, Internal, "gtk_plot_surface_set_ny");
   begin
      Internal (Get_Object (Data), Ny);
   end Set_Ny;

   ----------------
   -- Set_Points --
   ----------------

   procedure Set_Points
     (Data : access Gtk_Plot_Surface_Record;
      X    : Gdouble_Array_Access;
      Y    : Gdouble_Array_Access;
      Z    : Gdouble_Array_Access;
      Dx   : Gdouble_Array_Access;
      Dy   : Gdouble_Array_Access;
      Dz   : Gdouble_Array_Access)
   is
      procedure Internal
        (Data : System.Address;
         X    : System.Address;
         Y    : System.Address;
         Z    : System.Address;
         Dx   : System.Address;
         Dy   : System.Address;
         Dz   : System.Address;
         Nx   : Gint;
         Ny   : Gint);
      pragma Import (C, Internal, "gtk_plot_surface_set_points");
   begin
      pragma Assert (X'Length = Dx'Length);
      pragma Assert (Y'Length = Dy'Length);
      pragma Assert (Z'Length = Dz'Length);
      pragma Assert (Z'Length = X'Length * Y'Length);
      Internal (Get_Object (Data),
                X (X'First)'Address, Y (Y'First)'Address, Z (Z'First)'Address,
                Dx (Dx'First)'Address, Dy (Dy'First)'Address,
                Dz (Dz'First)'Address, X'Length, Y'Length);
   end Set_Points;

   ----------------
   -- Set_Shadow --
   ----------------

   procedure Set_Shadow
     (Data  : access Gtk_Plot_Surface_Record; Color : Gdk.Color.Gdk_Color)
   is
      procedure Internal (Data  : System.Address; Color : System.Address);
      pragma Import (C, Internal, "gtk_plot_surface_set_shadow");
      C : aliased Gdk_Color := Color;
   begin
      Internal (Get_Object (Data), C'Address);
   end Set_Shadow;

   ---------------
   -- Set_Xstep --
   ---------------

   procedure Set_Xstep (Data : access Gtk_Plot_Surface_Record; Step : Gdouble)
   is
      procedure Internal (Data  : System.Address; Xstep : Gdouble);
      pragma Import (C, Internal, "gtk_plot_surface_set_xstep");
   begin
      Internal (Get_Object (Data), Step);
   end Set_Xstep;

   ---------------
   -- Set_Ystep --
   ---------------

   procedure Set_Ystep (Data : access Gtk_Plot_Surface_Record; Step : Gdouble)
   is
      procedure Internal (Data  : System.Address; Ystep : Gdouble);
      pragma Import (C, Internal, "gtk_plot_surface_set_ystep");
   begin
      Internal (Get_Object (Data), Step);
   end Set_Ystep;

   ----------------
   -- Build_Mesh --
   ----------------

   procedure Build_Mesh (Data : access Gtk_Plot_Surface_Record) is
      procedure Internal (Data : System.Address);
      pragma Import (C, Internal, "gtk_plot_surface_build_mesh");
   begin
      Internal (Get_Object (Data));
   end Build_Mesh;

   ------------------
   -- Recalc_Nodes --
   ------------------

   procedure Recalc_Nodes (Data : access Gtk_Plot_Surface_Record) is
      procedure Internal (Data : System.Address);
      pragma Import (C, Internal, "gtk_plot_surface_recalc_nodes");
   begin
      Internal (Get_Object (Data));
   end Recalc_Nodes;

   -------------------------
   -- Use_Height_Gradient --
   -------------------------

   procedure Use_Height_Gradient
     (Data : access Gtk_Plot_Surface_Record; Use_Gradient : Boolean)
   is
      procedure Internal (Data : System.Address; Gradient : Integer);
      pragma Import (C, Internal, "gtk_plot_surface_use_height_gradient");
   begin
      Internal (Get_Object (Data), Boolean'Pos (Use_Gradient));
   end Use_Height_Gradient;

   ------------------
   -- Use_Amplitud --
   ------------------

   procedure Use_Amplitud
     (Data : access Gtk_Plot_Surface_Record; Amplitud : Boolean)
   is
      procedure Internal (Data : System.Address; Amplitud : Integer);
      pragma Import (C, Internal, "gtk_plot_surface_use_amplitud");
   begin
      Internal (Get_Object (Data), Boolean'Pos (Amplitud));
   end Use_Amplitud;

   ---------------------
   -- Set_Transparent --
   ---------------------

   procedure Set_Transparent
     (Data : access Gtk_Plot_Surface_Record; Transparent : Boolean)
   is
      procedure Internal (Data : System.Address; Transparent : Integer);
      pragma Import (C, Internal, "gtk_plot_surface_set_transparent");
   begin
      Internal (Get_Object (Data), Boolean'Pos (Transparent));
   end Set_Transparent;

end Gtk.Extra.Plot_Surface;