From: <ai...@us...> - 2007-07-02 01:08:09
|
Revision: 7732 http://plplot.svn.sourceforge.net/plplot/?rev=7732&view=rev Author: airwin Date: 2007-07-01 18:08:11 -0700 (Sun, 01 Jul 2007) Log Message: ----------- Rename files from plplotthin to plplot_thin form. Added Paths: ----------- trunk/bindings/ada/plplot_thin.adb trunk/bindings/ada/plplot_thin.ads Removed Paths: ------------- trunk/bindings/ada/plplotthin.adb trunk/bindings/ada/plplotthin.ads Copied: trunk/bindings/ada/plplot_thin.adb (from rev 7731, trunk/bindings/ada/plplotthin.adb) =================================================================== --- trunk/bindings/ada/plplot_thin.adb (rev 0) +++ trunk/bindings/ada/plplot_thin.adb 2007-07-02 01:08:11 UTC (rev 7732) @@ -0,0 +1,187 @@ +with Ada.Text_IO; +use Ada.Text_IO; + +package body PLplotThin is + + -- Find minimum in a 1D array. + function Vector_Min(x : Real_Vector) return Long_Float is + Result : Long_Float; + begin + Result := x(x'First); + for i in x'First+1..x'Last loop + Result := Long_Float'min(Result, x(i)); + end loop; + return Result; + end Vector_Min; + + + -- Find minimum and its location in a 1D array. + procedure Vector_Min(x : Real_Vector; + The_Minimum : out Long_Float; + Location_Of_Min : out Integer) is + begin + The_Minimum := x(x'First); + Location_Of_Min := x'First; + for i in x'First+1..x'Last loop + if x(i) < x(i - 1) then -- Finds the first of repeated mins. + The_Minimum := x(i); + Location_Of_Min := i; + end if; + end loop; + end Vector_Min; + + + -- Find maximum in a 1D array. + function Vector_Max(x : Real_Vector) return Long_Float is + Result : Long_Float; + begin + Result := x(x'First); + for i in x'First+1..x'Last loop + Result := Long_Float'max(Result, x(i)); + end loop; + return Result; + end Vector_Max; + + + -- Find maximum and its location in a 1D array. + procedure Vector_Max(x : Real_Vector; + The_Maximum : out Long_Float; + Location_Of_Max : out Integer) is + begin + The_Maximum := x(x'First); + Location_Of_Max := x'First; + for i in x'First+1..x'Last loop + if x(i) > x(i - 1) then -- Finds the first of repeated maxes. + The_Maximum := x(i); + Location_Of_Max := i; + end if; + end loop; + end Vector_Max; + + + -- Find minimum in a 2D array. + function Matrix_Min(x : Real_Matrix) return Long_Float is + Result : Long_Float := Long_Float'large; + begin + for j in x'First(2)..x'Last(2) loop + for i in x'First(1)..x'Last(1) loop + Result := Long_Float'Min(Result, x(i, j)); + end loop; + end loop; + return Result; + end Matrix_Min; + + + -- Find maximum in a 2D array. + function Matrix_Max(x : Real_Matrix) return Long_Float is + Result : Long_Float := Long_Float'small; + begin + for j in x'First(2)..x'Last(2) loop + for i in x'First(1)..x'Last(1) loop + Result := Long_Float'Max(Result, x(i, j)); + end loop; + end loop; + return Result; + end Matrix_Max; + + +-------------------------------------------------------------------------------- +-- Utility for passing matrices to C -- +-------------------------------------------------------------------------------- + + -- Take a Real_Matrix as defined in Ada.Numerics.Generic_Real_Arrays + -- and its instances and produce a 1D array of access variables to the + -- element located at the first column of each row. This is then suitable + -- for passing to an external C subroutine which expects a "2D array" in the + -- form of an array of pointers to "1D arrays" which in turn are pointers to + -- the first element of each row in C-land. This currently uses the GNAT + -- attribute Unrestricted_Access which makes it non-portable but allows the + -- accessing of the matrix elements without aliasing them, which is useful + -- because the Ada 2005 vector and matrix types are non-aliased. + + -- For more about the Unrestricted_Access attribute, see Implementation + -- Defined Attributes in the GNAT Reference Manual. + + -- TO-DO: Write a function which accepts x(Index, Index_Of_First_Column) + -- as an argument and returns a "proper" access variable using the method + -- discussed in "Ada as a Second Language," Second Edition, by Norman H. + -- Cohen, Section 19.3, for portability. This should remove GNAT dependence. + + function Matrix_To_Pointers(x : Real_Matrix) return Long_Float_Pointer_Array is + Index_Of_First_Column : Integer := x'First(2); + x_As_Pointers : Long_Float_Pointer_Array (x'range(1)); + begin + for Index in x'range(1) loop + x_As_Pointers(Index) := x(Index, Index_Of_First_Column)'Unrestricted_Access; + end loop; + return x_As_Pointers; + end Matrix_To_Pointers; + + +-------------------------------------------------------------------------------- +-- Functions for use from C or C++ only -- +-- (Not really ;). -- +-------------------------------------------------------------------------------- +-- THESE FUNCTIONS ^^^ ARE NOT IMPLEMENTED FOR THE ADA BINDING +-- EXCEPT FOR THE FOLLOWING. + + -- plparseopts here is an exact copy (exept for the name) of + -- Parse_Command_Line_Arguments in the thick binding. The reason for + -- departing from the usual method of simply pragma Import-ing as in + -- most or all of the other interfaces to C is because of the need to + -- figure out what the command lines arguments are by also pragma + -- Import-ing Gnat_Argc and Gnat_Argv. A single-argment version is made + -- at the request of the development team rather than the three-argument + -- version of the documetation. The caller specifies only the parse mode. + + -- Process options list using current options info. + procedure plparseopts(Mode : Parse_Mode_Type) is + + Gnat_Argc : aliased Integer; + pragma Import (C, Gnat_Argc); + + Gnat_Argv : System.Address; + pragma Import (C, Gnat_Argv); + + type Gnat_Argc_Access_Type is access all Integer; + Gnat_Argc_Access : Gnat_Argc_Access_Type; + + procedure + plparseopts_local(argc : Gnat_Argc_Access_Type; + argv : System.Address; + mode : Parse_Mode_Type); + pragma Import(C, plparseopts_local, "c_plparseopts"); + + begin + Gnat_Argc_Access := Gnat_Argc'access; + plparseopts_local(Gnat_Argc_Access, Gnat_Argv, Mode); + end plparseopts; + + + -- This is a three-argument version of plparseopts as indicated in the + -- documentation. + + -- Process options list using current options info. + procedure plparseopts + (Gnat_Argc : Integer; + Gnat_Argv : System.Address; + Mode : Parse_Mode_Type) is + + Gnat_Argc_Dummy : aliased Integer; + + type Gnat_Argc_Access_Type is access all Integer; + Gnat_Argc_Access : Gnat_Argc_Access_Type; + + procedure + plparseopts_local(argc : Gnat_Argc_Access_Type; + argv : System.Address; + mode : Parse_Mode_Type); + pragma Import(C, plparseopts_local, "c_plparseopts"); + + begin + Gnat_Argc_Dummy := Gnat_Argc; + Gnat_Argc_Access := Gnat_Argc_Dummy'access; + plparseopts_local(Gnat_Argc_Access, Gnat_Argv, Mode); + end plparseopts; + +end PLplotThin; Copied: trunk/bindings/ada/plplot_thin.ads (from rev 7731, trunk/bindings/ada/plplotthin.ads) =================================================================== --- trunk/bindings/ada/plplot_thin.ads (rev 0) +++ trunk/bindings/ada/plplot_thin.ads 2007-07-02 01:08:11 UTC (rev 7732) @@ -0,0 +1,1630 @@ + -- Copyright (C) 1992 Maurice J. LeBrun, Geoff Furnish, Tony Richardson. + -- Copyright (C) 2004 Alan W. Irwin + -- Copyright (C) 2004 Rafael Laboissiere + -- Copyright (C) 2004 Andrew Ross + + -- This file is part of PLplot. + + -- PLplot is free software; you can redistribute it and/or modify + -- it under the terms of the GNU Library General Public License as published + -- by the Free Software Foundation; either version 2 of the License, or + -- (at your option) any later version. + + -- PLplot 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 Library General Public License for more details. + + -- You should have received a copy of the GNU Library General Public License + -- along with PLplot; if not, write to the Free Software + -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + ---------------------------------------------------------------------------- + + +-- SOME NOTES ABOUT THE ADA BINDINGS (JB) +-- Some C-arguments of the form PLINT *a are supposed to point at 8-bit unsigned chars +-- and are said to carry information out of the function, according to the PLplot docs. +-- I hope that this is wrong and that they are really PLINTs like the API says. +-- I converted these as a : out PLINT. These are the only *-ed quantities that I set to "outs". + +-- I made the final arg in plscmap1l, rev, an array of PLBOOLs, not an in out +-- parameter; impossible to tell from C syntax which is intended, but I think +-- this is right. + +with + Interfaces.C, + Interfaces.C.Pointers, + System, + Ada.Text_IO, + Ada.Strings.Bounded, + Ada.Strings.Unbounded; +use + Interfaces.C, + Ada.Text_IO, + Ada.Strings.Bounded, + Ada.Strings.Unbounded; + +-- COMMENT THIS LINE IF YOUR COMPILER DOES NOT INCLUDE THESE +-- DEFINITIONS, FOR EXAMPLE, IF IT IS NOT ADA 2005 WITH ANNEX G.3 COMPLIANCE. +--with Ada.Numerics.Long_Real_Arrays; use Ada.Numerics.Long_Real_Arrays; + +package PLplotThin is + subtype PLINT is Integer; + subtype PLFLT is Long_Float; + PLfalse : constant Integer := 0; + PLtrue : constant Integer := 1; + subtype PLBOOL is Integer range PLfalse..PLtrue; + type PLUNICODE is range 0..2**32-1; + + type Boolean_Array_1D is array (Integer range <>) of Boolean; + type Integer_Array_1D is array (Integer range <>) of Integer; + + -- UN-COMMENT THESE TWO LINES IF YOUR COMPILER DOES NOT INCLUDE THESE + -- DEFINITIONS, FOR EXAMPLE, IF IT IS NOT ADA 2005 WITH ANNEX G.3 COMPLIANCE. + type Real_Vector is array (Integer range <>) of Long_Float; + type Real_Matrix is array (Integer range <>, Integer range <>) of Long_Float; + + subtype PL_Integer_Array is Integer_Array_1D; + subtype PL_Float_Array is Real_Vector; + subtype PL_Float_Array_2D is Real_Matrix; + type PL_Bool_Array is array (Integer range <>) of PLBOOL; + subtype PLPointer is System.Address; -- non-specific pointer to something + + -- Types to pass 2D arrays (matrix) defined in Ada.Numerics.Generic_Real_Arrays + -- (and its instances) to C functions. Have only Long_Float capability for now. + type Long_Float_Pointer is access all Long_Float; + type Long_Float_Pointer_Array is array (Integer range <>) of Long_Float_Pointer; + + +-------------------------------------------------------------------------------- +-- PROCEDURE DECLARATIONS -- +-------------------------------------------------------------------------------- + + -- Find minimum in a 1D array. + function Vector_Min(x : Real_Vector) return Long_Float; + + -- Find minimum and its location in a 1D array. + procedure Vector_Min(x : Real_Vector; + The_Minimum : out Long_Float; + Location_Of_Min : out Integer); + + -- Find maximum in a 1D array. + function Vector_Max(x : Real_Vector) return Long_Float; + + -- Find maximum and its location in a 1D array. + procedure Vector_Max(x : Real_Vector; + The_Maximum : out Long_Float; + Location_Of_Max : out Integer); + + -- Find minimum in a 2D array. + function Matrix_Min(x : Real_Matrix) return Long_Float; + + -- Find maximum in a 2D array. + function Matrix_Max(x : Real_Matrix) return Long_Float; + + +-------------------------------------------------------------------------------- +-- Utility for passing matrices to C -- +-------------------------------------------------------------------------------- + + function Matrix_To_Pointers(x : Real_Matrix) return Long_Float_Pointer_Array; + + +-------------------------------------------------------------------------------- +-- Convenient string things -- +-------------------------------------------------------------------------------- + + -- Short name for To_Unbounded_String + function TUB(arg : String) return Ada.Strings.Unbounded.Unbounded_String renames Ada.Strings.Unbounded.To_Unbounded_String; + + -- Convenient string of length 80 + package Bounded_String_80 is + new Ada.Strings.Bounded.Generic_Bounded_Length(80); + subtype String_80 is Bounded_String_80.Bounded_String; + + +-------------------------------------------------------------------------------- +-- PLplot-specific things -- +-------------------------------------------------------------------------------- + + type Stripchart_String_Array is array (1..4) of char_array(1..3); + + + -- Access-to-procedure type for Draw_Vector_Plot and its kin. + type Transformation_Procedure_Pointer_Type is access + procedure (x, y : PLFLT; tx, ty : out PLFLT; pltr_data : PLpointer); + + + -- Access-to-function type for Shade_Regions (aka plshades). + -- Returns 1 if point is to be plotted, 0 if not. + type Mask_Function_Pointer_Type is access + function (x, y : PLFLT) return Integer; + + + -- Access-to-procedure type for filling polygons; example is plfill. + type Fill_Polygon_Procedure_Pointer_Type is access + procedure (n : Integer; x, y : PL_Float_Array); + + + -- Access-to-procedure type for plotting map outlines (continents). + -- Length_Of_x is x'Length or y'Length; this is the easiest way to match the + -- C formal arguments. + type Map_Form_Function_Pointer_Type is access + procedure (Length_Of_x : Integer; x, y : PL_Float_Array); + + + -- Access-to-function type for making contour plots from irregularly + -- spaced data which is stored in a 2D array accessed by a single pointer. + -- Examples of such functions are in plplot.h and are called plf2eval, + -- plf2eval2, plf2evalr. + type Function_Evaluator_Pointer_Type is access + function (ix, iy : PLINT; Irregular_Data : PLpointer) return PLFLT; + + +-------------------------------------------------------------------------------- +-- Argument parsing things -- +-------------------------------------------------------------------------------- + + Gnat_argc : aliased Integer; + pragma Import (C, Gnat_argc); + + Gnat_argv : System.Address; -- Just get the base address to argv, like C + pragma Import (C, Gnat_argv); + + +-------------------------------------------------------------------------------- +-- More PLplot-specific things -- +-------------------------------------------------------------------------------- + + -- Switches for escape function call. + -- Some of these are obsolete but are retained in order to process + -- old metafiles + + PLESC_SET_RGB : constant Integer := 1; -- obsolete + PLESC_ALLOC_NCOL : constant Integer := 2; -- obsolete + PLESC_SET_LPB : constant Integer := 3; -- obsolete + PLESC_EXPOSE : constant Integer := 4; -- handle window expose + PLESC_RESIZE : constant Integer := 5; -- handle window resize + PLESC_REDRAW : constant Integer := 6; -- handle window redraw + PLESC_TEXT : constant Integer := 7; -- switch to text screen + PLESC_GRAPH : constant Integer := 8; -- switch to graphics screen + PLESC_FILL : constant Integer := 9; -- fill polygon + PLESC_DI : constant Integer := 10; -- handle DI command + PLESC_FLUSH : constant Integer := 11; -- flush output + PLESC_EH : constant Integer := 12; -- handle Window events + PLESC_GETC : constant Integer := 13; -- get cursor position + PLESC_SWIN : constant Integer := 14; -- set window parameters + PLESC_DOUBLEBUFFERING : constant Integer := 15; -- configure double buffering + PLESC_XORMOD : constant Integer := 16; -- set xor mode + PLESC_SET_COMPRESSION : constant Integer := 17; -- AFR: set compression + PLESC_CLEAR : constant Integer := 18; -- RL: clear graphics region + PLESC_DASH : constant Integer := 19; -- RL: draw dashed line + PLESC_HAS_TEXT : constant Integer := 20; -- driver draws text + PLESC_IMAGE : constant Integer := 21; -- handle image + PLESC_IMAGEOPS : constant Integer := 22; -- plimage related operations + PLESC_PL2DEVCOL : constant Integer := 23; -- convert PLColor to device color + PLESC_DEV2PLCOL : constant Integer := 24; -- convert device color to PLColor + PLESC_SETBGFG : constant Integer := 25; -- set BG, FG colors + PLESC_DEVINIT : constant Integer := 26; -- alternate device initialization + + -- image operations + ZEROW2B : constant Integer := 1; + ZEROW2D : constant Integer := 2; + ONEW2B : constant Integer := 3; + ONEW2D : constant Integer := 4; + + -- Window parameter tags + + PLSWIN_DEVICE : constant Integer := 1; -- device coordinates + PLSWIN_WORLD : constant Integer := 2; -- world coordinates + + -- PLplot Option table & support constants + + -- Option-specific settings + + PL_OPT_ENABLED : constant Integer := 16#0001#; -- Obsolete + PL_OPT_ARG : constant Integer := 16#0002#; -- Option has an argment + PL_OPT_NODELETE : constant Integer := 16#0004#; -- Don't delete after processing + PL_OPT_INVISIBLE : constant Integer := 16#0008#; -- Make invisible + PL_OPT_DISABLED : constant Integer := 16#0010#; -- Processing is disabled + + -- Option-processing settings -- mutually exclusive + + PL_OPT_FUNC : constant Integer := 16#0100#; -- Call handler function + PL_OPT_BOOL : constant Integer := 16#0200#; -- Set *var = 1 + PL_OPT_INT : constant Integer := 16#0400#; -- Set *var = atoi(optarg) + PL_OPT_FLOAT : constant Integer := 16#0800#; -- Set *var = atof(optarg) + PL_OPT_STRING : constant Integer := 16#1000#; -- Set var = optarg + + -- Global mode settings + -- These override per-option settings + + type Parse_Mode_Type is range 16#0000# .. 16#0001# + 16#0002# + 16#0004# + + 16#0008# + 16#0010# + 16#0020# + 16#0040# + 16#0080#; + + PL_PARSE_PARTIAL : constant Parse_Mode_Type := 16#0000#; -- For backward compatibility + PL_PARSE_FULL : constant Parse_Mode_Type := 16#0001#; -- Process fully & exit if error + PL_PARSE_QUIET : constant Parse_Mode_Type := 16#0002#; -- Don't issue messages + PL_PARSE_NODELETE : constant Parse_Mode_Type := 16#0004#; -- Don't delete options after processing + PL_PARSE_SHOWALL : constant Parse_Mode_Type := 16#0008#; -- Show invisible options + PL_PARSE_OVERRIDE : constant Parse_Mode_Type := 16#0010#; -- Obsolete + PL_PARSE_NOPROGRAM : constant Parse_Mode_Type := 16#0020#; -- Program name NOT in *argv[0].. + PL_PARSE_NODASH : constant Parse_Mode_Type := 16#0040#; -- Set if leading dash NOT required + PL_PARSE_SKIP : constant Parse_Mode_Type := 16#0080#; -- Skip over unrecognized args + + -- FCI (font characterization integer) related constants. + PL_FCI_MARK : constant Integer := 16#10000000#; + PL_FCI_IMPOSSIBLE : constant Integer := 16#00000000#; + PL_FCI_HEXDIGIT_MASK : constant Integer := 16#f#; + PL_FCI_HEXPOWER_MASK : constant Integer := 16#7#; + PL_FCI_HEXPOWER_IMPOSSIBLE : constant Integer := 16#f#; + -- These define hexpower values corresponding to each font attribute. + PL_FCI_FAMILY : constant Integer := 16#0#; + PL_FCI_STYLE : constant Integer := 16#1#; + PL_FCI_WEIGHT : constant Integer := 16#2#; + -- These are legal values for font family attribute + PL_FCI_SANS : constant Integer := 16#0#; + PL_FCI_SERIF : constant Integer := 16#1#; + PL_FCI_MONO : constant Integer := 16#2#; + PL_FCI_SCRIPT : constant Integer := 16#3#; + PL_FCI_SYMBOL : constant Integer := 16#4#; + -- These are legal values for font style attribute + PL_FCI_UPRIGHT : constant Integer := 16#0#; + PL_FCI_ITALIC : constant Integer := 16#1#; + PL_FCI_OBLIQUE : constant Integer := 16#2#; + -- These are legal values for font weight attribute + PL_FCI_MEDIUM : constant Integer := 16#0#; + PL_FCI_BOLD : constant Integer := 16#1#; + + -- fix this + --type PLOptionTable is + -- record + -- opt : char_array; + -- int (*handler) (char *, char *, void *); + -- void *client_data; + -- void *var; + -- mode : long; + -- syntax : char_array; + -- desc : char_array; + -- end record; + + -- PLplot Graphics Input structure + + PL_MAXKEY : constant Integer := 16; + + -- fix this + --type PLGraphicsIn is + -- record + -- PLGraphicsIn_type : integer; -- of event (CURRENTLY UNUSED); Renamed to un-clobber Ada reserved word. + -- state : unsigned; -- key or button mask + -- keysym : unsigned; -- key selected + -- button : unsigned; -- mouse button selected + -- subwindow : PLINT; -- subwindow (alias subpage, alias subplot) number + -- char string[PL_MAXKEY]; -- translated string + -- pX, pY : integer; -- absolute device coordinates of pointer + -- dX, dY : PLFLT; -- relative device coordinates of pointer + -- wX, wY : PLFLT; -- world coordinates of pointer + -- end record; + + -- Structure for describing the plot window + + PL_MAXWINDOWS : constant Integer := 64; -- Max number of windows/page tracked + + type PLWindow is + record + dxmi, dxma, dymi, dyma : PLFLT; -- min, max window rel dev coords + wxmi, wxma, wymi, wyma : PLFLT; -- min, max window world coords + end record; + + -- Structure for doing display-oriented operations via escape commands + -- May add other attributes in time + + type PLDisplay is + record + x, y : unsigned; -- upper left hand corner + width, height : unsigned; -- window dimensions + end record; + + -- Macro used (in some cases) to ignore value of argument + -- I don't plan on changing the value so you can hard-code it + + PL_NOTSET : constant := -42; + PL_NOTSET_Float : constant := -42.0; -- Added for Ada binding. + + -- See plcont.c for examples of the following + + + -- PLfGrid is for passing (as a pointer to the first element) an arbitrarily + -- dimensioned array. The grid dimensions MUST be stored, with a maximum of 3 + -- dimensions assumed for now. + + + -- fix this I don't think Ada needs this. If otherwise, set an object of + -- type PLpointer to the 'Address attribute of the array. + -- type PLfGrid is + -- record + -- f : PL_Float_Array; + -- nx, ny, nz : PLINT; + -- end record; + + -- + -- PLfGrid2 is for passing (as an array of pointers) a 2d function array. The + -- grid dimensions are passed for possible bounds checking. + + + -- fix this I don't think Ada needs this since we use the procedure + -- Matrix_To_Pointers. + -- type PLfGrid2 is + -- record + -- f : PL_Float_Array; + -- nx, ny : PLINt; + -- end record; + + -- + -- NOTE: a PLfGrid3 is a good idea here but there is no way to exploit it yet + -- so I'll leave it out for now. + + + -- PLcGrid is for passing (as a pointer to the first element) arbitrarily + -- dimensioned coordinate transformation arrays. The grid dimensions MUST be + -- stored, with a maximum of 3 dimensions assumed for now. + + -- This variant record emulates PLcGrid. Use it in plvect, plcont, plfcont, + -- plshade, c_plshade1, c_plshades, plfshade, plf2eval2, plf2eval, plf2evalr, + -- PLcGrid and Ada counterparts thereof. + type Transformation_Data_Type (x_Length_Minus_1, y_Length_Minus_1, z_Length_Minus_1 : Positive) is + record + xg : PL_Float_Array(0 .. x_Length_Minus_1); -- no way to index from anything but 1? + yg : PL_Float_Array(0 .. y_Length_Minus_1); + zg : PL_Float_Array(0 .. z_Length_Minus_1); + nx : Positive := x_Length_Minus_1 + 1; + ny : Positive := y_Length_Minus_1 + 1; + nz : Positive := z_Length_Minus_1 + 1; + end record; + + + -- PLcGrid2 is for passing (as arrays of pointers) 2d coordinate + -- transformation arrays. The grid dimensions are passed for possible bounds + -- checking. + + -- This variant record emulates PLcGrid2. + type Transformation_Data_Type_2 (x_Length_Minus_1, y_Length_Minus_1 : Positive) is + record + xg : PL_Float_Array_2D(0 .. x_Length_Minus_1, 0 .. y_Length_Minus_1); + yg : PL_Float_Array_2D(0 .. x_Length_Minus_1, 0 .. y_Length_Minus_1); + zg : PL_Float_Array_2D(0 .. x_Length_Minus_1, 0 .. y_Length_Minus_1); + nx : Positive := x_Length_Minus_1 + 1; + ny : Positive := y_Length_Minus_1 + 1; + end record; + + + --NOTE: a PLcGrid3 is a good idea here but there is no way to exploit it yet + --so I'll leave it out for now. + + + -- PLColor is the usual way to pass an rgb color value. + -- fix this + -- This can't be converted to Ada without knowing what "name" is used for. + -- There is nothing in the documentation about this structure nor is it used + -- in any of the examples. + --type PLColor is + -- record + -- r : unsigned_char; -- red fix this surely these can be mod 2**3 + -- g : unsigned_char; -- green + -- b : unsigned_char; -- blue + -- name : char_array; + -- end record; + + -- PLControlPt is how cmap1 control points are represented. + + type PLControlPt is + record + h : PLFLT; -- hue + l : PLFLT; -- lightness + s : PLFLT; -- saturation + p : PLFLT; -- position + rev : Integer; -- if set, interpolate through h=0 + end record; + + -- A PLBufferingCB is a control block for interacting with devices + -- that support double buffering. + + type PLBufferingCB is + record + cmd : PLINT; + result : PLINT; + end record; + + PLESC_DOUBLEBUFFERING_ENABLE : constant Integer := 1; + PLESC_DOUBLEBUFFERING_DISABLE : constant Integer := 2; + PLESC_DOUBLEBUFFERING_QUERY : constant Integer := 3; + + +-------------------------------------------------------------------------- +-- Function Prototypes -- +-------------------------------------------------------------------------- + + -- set the format of the contour labels + + procedure + pl_setcontlabelformat(lexp : PLINT; sigdig : PLINT); + pragma Import(C, pl_setcontlabelformat, "c_pl_setcontlabelformat"); + + + -- set offset and spacing of contour labels + + procedure + pl_setcontlabelparam(offset : PLFLT; size : PLFLT; spacing : PLFLT; active : PLINT); + pragma Import(C, pl_setcontlabelparam, "c_pl_setcontlabelparam"); + + + -- Advance to subpage "page", or to the next one if "page" = 0. + + procedure + pladv(page : PLINT); + pragma Import(C, pladv, "c_pladv"); + + + -- simple arrow plotter. + + procedure + plarrows(u : PL_Float_Array; v : PL_Float_Array; x : PL_Float_Array; y : PL_Float_Array; n : PLINT; + scale : PLFLT; dx : PLFLT; dy : PLFLT) ; + pragma Import(C, plarrows, "plarrows"); + + + procedure + plvect(u : Long_Float_Pointer_Array; v : Long_Float_Pointer_Array; + nx : PLINT; ny : PLINT; scale : PLFLT; + pltr : Transformation_Procedure_Pointer_Type; pltr_data : PLpointer); + pragma Import(C, plvect, "c_plvect"); + + + procedure + plsvect(arrowx : PL_Float_Array; arrowy : PL_Float_Array; npts : PLINT; fill : PLINT); + pragma Import(C, plsvect, "c_plsvect"); + + + -- This functions similarly to plbox() except that the origin of the axes + -- is placed at the user-specified point (x0, y0). + + procedure + plaxes(x0 : PLFLT; y0 : PLFLT; xopt : char_array; xtick : PLFLT; nxsub : PLINT; + yopt : char_array; ytick : PLFLT; nysub : PLINT); + pragma Import(C, plaxes, "c_plaxes"); + + + -- Plot a histogram using x to store data values and y to store frequencies + + procedure + plbin(nbin : PLINT; x : PL_Float_Array; y : PL_Float_Array; center : PLINT); + pragma Import(C, plbin, "c_plbin"); + + + -- Start new page. Should only be used with pleop(). + + procedure + plbop; + pragma Import(C, plbop, "c_plbop"); + + + -- This draws a box around the current viewport. + + procedure + plbox(xopt : char_array; xtick : PLFLT; nxsub : PLINT; + yopt : char_array; ytick : PLFLT; nysub : PLINT); + pragma Import(C, plbox, "c_plbox"); + + + -- This is the 3-d analogue of plbox(). + + procedure + plbox3(xopt : char_array; xlabel : char_array; xtick : PLFLT; nsubx : PLINT; + yopt : char_array; ylabel : char_array; ytick : PLFLT; nsuby : PLINT; + zopt : char_array; zlabel : char_array; ztick : PLFLT; nsubz : PLINT); + pragma Import(C, plbox3, "c_plbox3"); + + + -- Calculate world coordinates and subpage from relative device coordinates. + + procedure + plcalc_world(rx : PLFLT; ry : PLFLT; wx : out PLFLT; wy : out PLFLT; window : out PLINT); + pragma Import(C, plcalc_world, "c_plcalc_world"); + + + -- Clear current subpage. + + procedure + plclear; + pragma Import(C, plclear, "c_plclear"); + + + -- Set color, map 0. Argument is integer between 0 and 15. + + procedure + plcol0(icol0 : PLINT); + pragma Import(C, plcol0, "c_plcol0"); + + + -- Set color, map 1. Argument is a float between 0. and 1. + + procedure + plcol1(col1 : PLFLT); + pragma Import(C, plcol1, "c_plcol1"); + + + -- Draws a contour plot from data in f(nx,ny). Is just a front-end to + -- plfcont, with a particular choice for f2eval and f2eval_data. + + procedure + plcont(z : Long_Float_Pointer_Array; nx, ny : Integer; + kx, lx, ky, ly : Integer; clevel : PL_Float_Array; nlevel : Integer; + pltr : Transformation_Procedure_Pointer_Type; pltr_data : PLpointer); + pragma Import(C, plcont, "c_plcont"); + + + -- Draws a contour plot using the function evaluator f2eval and data stored + -- by way of the f2eval_data pointer. This allows arbitrary organizations + -- of 2d array data to be used. + + procedure + plfcont(f2eval : Function_Evaluator_Pointer_Type; + Irregular_Data : PLpointer; + nx, ny : PLINT; + kx, lx, ky, ly: PLINT; clevel : PL_Float_Array; nlevel : PLINT; + pltr : Transformation_Procedure_Pointer_Type; pltr_data : PLpointer); + pragma Import(C, plfcont, "plfcont"); + + + -- Copies state parameters from the reference stream to the current stream. + + procedure + plcpstrm(iplsr : PLINT; flags : PLINT); + pragma Import(C, plcpstrm, "c_plcpstrm"); + + + -- Converts input values from relative device coordinates to relative plot + -- coordinates. + + procedure + pldid2pc(xmin : PL_Float_Array; ymin : PL_Float_Array; xmax : PL_Float_Array; ymax : PL_Float_Array); + pragma Import(C, pldid2pc, "pldid2pc"); + + -- Converts input values from relative plot coordinates to relative + -- device coordinates. + + procedure + pldip2dc(xmin : PL_Float_Array; ymin : PL_Float_Array; xmax : PL_Float_Array; ymax : PL_Float_Array); + pragma Import(C, pldip2dc, "pldip2dc"); + + -- End a plotting session for all open streams. + + procedure + plend; + pragma Import(C, plend, "c_plend"); + + + -- End a plotting session for the current stream only. + + procedure + plend1; + pragma Import(C, plend1, "c_plend1"); + + + -- Simple interface for defining viewport and window. + + procedure + plenv(xmin : PLFLT; xmax : PLFLT; ymin : PLFLT; ymax : PLFLT; + just : PLINT; axis : PLINT); + pragma Import(C, plenv, "c_plenv"); + + + + -- similar to plenv() above, but in multiplot mode does not advance the subpage, + -- instead the current subpage is cleared + + procedure + plenv0(xmin : PLFLT; xmax : PLFLT; ymin : PLFLT; ymax : PLFLT; + just : PLINT; axis : PLINT); + pragma Import(C, plenv0, "c_plenv0"); + + + -- End current page. Should only be used with plbop(). + + procedure + pleop; + pragma Import(C, pleop, "c_pleop"); + + + -- Plot horizontal error bars (xmin(i),y(i)) to (xmax(i),y(i)) + + procedure + plerrx(n : PLINT; xmin : PL_Float_Array; xmax : PL_Float_Array; y : PL_Float_Array); + pragma Import(C, plerrx, "c_plerrx"); + + + -- Plot vertical error bars (x,ymin(i)) to (x(i),ymax(i)) + + procedure + plerry(n : PLINT; x : PL_Float_Array; ymin : PL_Float_Array; ymax : PL_Float_Array); + pragma Import(C, plerry, "c_plerry"); + + + -- Advance to the next family file on the next new page + + procedure + plfamadv; + pragma Import(C, plfamadv, "c_plfamadv"); + + + -- Pattern fills the polygon bounded by the input points. + -- (This Ada variation required by plplot.adb). + + procedure + plfillada(n : PLINT; x : PL_Float_Array; y : PL_Float_Array); + pragma Import(Ada, plfillada, "c_plfill"); + + + -- Pattern fills the polygon bounded by the input points. + + procedure + plfill(n : PLINT; x : PL_Float_Array; y : PL_Float_Array); + pragma Import(C, plfill, "c_plfill"); + + + -- Pattern fills the 3d polygon bounded by the input points. + + procedure + plfill3(n : PLINT; x : PL_Float_Array; y : PL_Float_Array; z : PL_Float_Array); + pragma Import(C, plfill3, "c_plfill3"); + + + -- Flushes the output stream. Use sparingly, if at all. + + procedure + plflush; + pragma Import(C, plflush, "c_plflush"); + + + -- Sets the global font flag to 'ifont'. + + procedure + plfont(ifont : PLINT); + pragma Import(C, plfont, "c_plfont"); + + + -- Load specified font set. + + procedure + plfontld(fnt : PLINT); + pragma Import(C, plfontld, "c_plfontld"); + + + -- Get character default height and current (scaled) height + + procedure + plgchr(p_def : out PLFLT; p_ht : out PLFLT); + pragma Import(C, plgchr, "c_plgchr"); + + + -- Returns 8 bit RGB values for given color from color map 0 + + procedure + plgcol0(icol0 : PLINT; r : out PLINT; g : out PLINT; b : out PLINT); + pragma Import(C, plgcol0, "c_plgcol0"); + + + -- Returns the background color by 8 bit RGB value + + procedure + plgcolbg(r : out PLINT; g : out PLINT; b : out PLINT); + pragma Import(C, plgcolbg, "c_plgcolbg"); + + + -- Returns the current compression setting + + procedure + plgcompression(compression : out PLINT); + pragma Import(C, plgcompression, "c_plgcompression"); + + + -- Get the current device (keyword) name + + procedure + plgdev(p_dev : out char_array); + pragma Import(C, plgdev, "c_plgdev"); + + + -- Retrieve current window into device space + + procedure + plgdidev(p_mar : out PLFLT; p_aspect : out PLFLT; p_jx : out PLFLT; p_jy : out PLFLT); + pragma Import(C, plgdidev, "c_plgdidev"); + + + -- Get plot orientation + + procedure + plgdiori(p_rot : out PLFLT); + pragma Import(C, plgdiori, "c_plgdiori"); + + + -- Retrieve current window into plot space + + procedure + plgdiplt(p_xmin : out PLFLT; p_ymin : out PLFLT; p_xmax : out PLFLT; p_ymax : out PLFLT); + pragma Import(C, plgdiplt, "c_plgdiplt"); + + + -- Get FCI (font characterization integer) + + procedure + plgfci(pfci : out PLUNICODE); + pragma Import(C, plgfci, "c_plgfci"); + + + -- Get family file parameters + + procedure + plgfam(p_fam : out PLINT; p_num : out PLINT; p_bmax : out PLINT); + pragma Import(C, plgfam, "c_plgfam"); + + + -- Get the (current) output file name. Must be preallocated to >80 bytes + + procedure + plgfnam(fnam : out char_array); + pragma Import(C, plgfnam, "c_plgfnam"); + + + -- Get the (current) run level. + + procedure + plglevel(p_level : out PLINT); + pragma Import(C, plglevel, "c_plglevel"); + + + -- Get output device parameters. + + procedure + plgpage(p_xp : out PLFLT; p_yp : out PLFLT; + p_xleng : out PLINT; p_yleng : out PLINT; p_xoff : out PLINT; p_yoff : out PLINT); + pragma Import(C, plgpage, "c_plgpage"); + + + -- Switches to graphics screen. + + procedure + plgra; + pragma Import(C, plgra, "c_plgra"); + + + -- grid irregularly sampled data + -- Note that since z_Gridded is passed as an array of pointers, this is + -- effectively the same as pass-by-reference so "in out" is not required for + -- the formal argument zg in plgriddata. + + procedure + plgriddata(x : PL_Float_Array; y : PL_Float_Array; z : PL_Float_Array; npts : PLINT; + xg : PL_Float_Array; nptsx : PLINT; yg : PL_Float_Array; nptsy : PLINT; + zg : Long_Float_Pointer_Array; grid_type : PLINT; data : PLFLT); --"type" re-named "grid_type" for Ada + pragma Import(C, plgriddata, "c_plgriddata"); + + + -- type of gridding algorithm for plgriddata() + + GRID_CSA : constant Integer := 1; -- Bivariate Cubic Spline approximation + GRID_DTLI : constant Integer := 2; -- Delaunay Triangulation Linear Interpolation + GRID_NNI : constant Integer := 3; -- Natural Neighbors Interpolation + GRID_NNIDW : constant Integer := 4;-- Nearest Neighbors Inverse Distance Weighted + GRID_NNLI : constant Integer := 5; -- Nearest Neighbors Linear Interpolation + GRID_NNAIDW : constant Integer := 6; -- Nearest Neighbors Around Inverse Distance Weighted + + -- Get subpage boundaries in absolute coordinates + + procedure + plgspa(xmin : out PLFLT; xmax : out PLFLT; ymin : out PLFLT; ymax : out PLFLT); + pragma Import(C, plgspa, "c_plgspa"); + + + -- Get current stream number. + + procedure + plgstrm(p_strm : out PLINT); + pragma Import(C, plgstrm, "c_plgstrm"); + + + -- Get the current library version number + + procedure + plgver(p_ver : out char_array); + pragma Import(C, plgver, "c_plgver"); + + + -- Get viewport boundaries in normalized device coordinates + + procedure + plgvpd(p_xmin : out PLFLT; p_xmax : out PLFLT; p_ymin : out PLFLT; p_ymax : out PLFLT); + pragma Import(C, plgvpd, "c_plgvpd"); + + + -- Get viewport boundaries in world coordinates + + procedure + plgvpw(p_xmin : out PLFLT; p_xmax : out PLFLT; p_ymin : out PLFLT; p_ymax : out PLFLT); + pragma Import(C, plgvpw, "c_plgvpw"); + + + -- Get x axis labeling parameters + + procedure + plgxax(p_digmax : out PLINT; p_digits : out PLINT); + pragma Import(C, plgxax, "c_plgxax"); + + + -- Get y axis labeling parameters + + procedure + plgyax(p_digmax : out PLINT; p_digits : out PLINT); + pragma Import(C, plgyax, "c_plgyax"); + + + -- Get z axis labeling parameters + + procedure + plgzax(p_digmax : out PLINT; p_digits : out PLINT); + pragma Import(C, plgzax, "c_plgzax"); + + + -- Draws a histogram of n values of a variable in array data[0..n-1] + + procedure + plhist(n : PLINT; data : PL_Float_Array; datmin : PLFLT; datmax : PLFLT; + nbin : PLINT; oldwin : PLINT); + pragma Import(C, plhist, "c_plhist"); + + + -- Set current color (map 0) by hue, lightness, and saturation. + + procedure + plhls(h : PLFLT; l : PLFLT; s : PLFLT); + pragma Import(C, plhls, "c_plhls"); + + + -- Functions for converting between HLS and RGB color space + + procedure + plhlsrgb(h : PLFLT; l : PLFLT; s : PLFLT; p_r : out PLFLT; p_g : out PLFLT; p_b : out PLFLT); + pragma Import(C, plhlsrgb, "c_plhlsrgb"); + + + -- Initializes PLplot, using preset or default options + + procedure + plinit; + pragma Import(C, plinit, "c_plinit"); + + + -- Draws a line segment from (x1, y1) to (x2, y2). + + procedure + pljoin(x1 : PLFLT; y1 : PLFLT; x2 : PLFLT; y2 : PLFLT); + pragma Import(C, pljoin, "c_pljoin"); + + + -- Simple routine for labelling graphs. + + procedure + pllab(xlabel : char_array; ylabel : char_array; tlabel : char_array); + pragma Import(C, pllab, "c_pllab"); + + + -- Sets position of the light source + + procedure + pllightsource(x : PLFLT; y : PLFLT; z : PLFLT); + pragma Import(C, pllightsource, "c_pllightsource"); + + + -- Draws line segments connecting a series of points. + + procedure + plline(n : PLINT; x : PL_Float_Array; y : PL_Float_Array); + pragma Import(C, plline, "c_plline"); + + + -- Draws a line in 3 space. + + procedure + plline3(n : PLINT; x : PL_Float_Array; y : PL_Float_Array; z : PL_Float_Array); + pragma Import(C, plline3, "c_plline3"); + + + -- Set line style. + + procedure + pllsty(lin : PLINT); + pragma Import(C, pllsty, "c_pllsty"); + + + -- plot continental outline in world coordinates + + procedure + plmap(mapform : Map_Form_Function_Pointer_Type; Map_Kind_C_String : char_array; + minlong : PLFLT; maxlong : PLFLT; minlat : PLFLT; maxlat : PLFLT); + pragma Import(C, plmap, "c_plmap"); + + + -- Plot the latitudes and longitudes on the background. + + procedure + plmeridians(mapform : Map_Form_Function_Pointer_Type; + dlong : PLFLT; dlat : PLFLT; + minlong : PLFLT; maxlong : PLFLT; minlat : PLFLT; maxlat : PLFLT); + pragma Import(C, plmeridians, "c_plmeridians"); + + + -- Plots a mesh representation of the function z[x][y]. + + procedure + plmesh(x : PL_Float_Array; y : PL_Float_Array; z : Long_Float_Pointer_Array; nx : PLINT; ny : PLINT; opt : PLINT); + pragma Import(C, plmesh, "c_plmesh"); + + + -- Plots a mesh representation of the function z[x][y] with contour + + procedure + plmeshc(x : PL_Float_Array; y : PL_Float_Array; z : Long_Float_Pointer_Array; nx : PLINT; ny : PLINT; opt : PLINT; + clevel : PL_Float_Array; nlevel : PLINT); + pragma Import(C, plmeshc, "c_plmeshc"); + + + -- Creates a new stream and makes it the default. + + procedure + plmkstrm(p_strm : out PLINT); + pragma Import(C, plmkstrm, "c_plmkstrm"); + + + -- Prints out "text" at specified position relative to viewport + + procedure + plmtex(side : char_array; disp : PLFLT; pos : PLFLT; just : PLFLT; + text : char_array); + pragma Import(C, plmtex, "c_plmtex"); + + + -- Plots a 3-d representation of the function z[x][y]. + + procedure + plot3d(x : PL_Float_Array; y : PL_Float_Array; z : Long_Float_Pointer_Array; + nx : PLINT; ny : PLINT; opt : PLINT; side : PLINT); + pragma Import(C, plot3d, "c_plot3d"); + + + -- Plots a 3-d representation of the function z[x][y] with contour. + + procedure + plot3dc(x : PL_Float_Array; y : PL_Float_Array; z : Long_Float_Pointer_Array; + nx : PLINT; ny : PLINT; opt : PLINT; + clevel : PL_Float_Array; nlevel : PLINT); + pragma Import(C, plot3dc, "c_plot3dc"); + + + -- Plots a 3-d representation of the function z[x][y] with contour and + -- y index limits. + + procedure + plot3dcl(x : PL_Float_Array; y : PL_Float_Array; z : Long_Float_Pointer_Array; + nx : PLINT; ny : PLINT; opt : PLINT; + clevel : PL_Float_Array; nlevel : PLINT; + ixstart : PLINT; ixn : PLINT; indexymin : PL_Integer_Array; indexymax : PL_Integer_Array); + pragma Import(C, plot3dcl, "c_plot3dcl"); + + + -- definitions for the opt argument in plot3dc() and plsurf3d() + + -- DRAW_LINEX *must* be 1 and DRAW_LINEY *must* be 2, because of legacy code! + + DRAW_LINEX : constant Integer := 1; -- draw lines parallel to the X axis + DRAW_LINEY : constant Integer := 2; -- draw lines parallel to the Y axis + DRAW_LINEXY : constant Integer := 3; -- draw lines parallel to both the X and Y axis + MAG_COLOR : constant Integer := 4; -- draw the mesh with a color dependent of the magnitude + BASE_CONT : constant Integer := 8; -- draw contour plot at bottom xy plane + TOP_CONT : constant Integer := 16; -- draw contour plot at top xy plane + SURF_CONT : constant Integer := 32; -- draw contour plot at surface + DRAW_SIDES : constant Integer := 64; -- draw sides + FACETED : constant Integer := 128; -- draw outline for each square that makes up the surface + MESH : constant Integer := 256; -- draw mesh + + -- valid options for plot3dc(): + -- + -- DRAW_SIDES, BASE_CONT, TOP_CONT (not yet), + -- MAG_COLOR, DRAW_LINEX, DRAW_LINEY, DRAW_LINEXY. + -- + -- valid options for plsurf3d(): + -- + -- MAG_COLOR, BASE_CONT, SURF_CONT, FACETED, DRAW_SIDES. + + + -- Set fill pattern directly. + + procedure + plpat(nlin : PLINT; inc : PL_Integer_Array; del : PL_Integer_Array); + pragma Import(C, plpat, "c_plpat"); + + + -- Plots array y against x for n points using ASCII code "code". + + procedure + plpoin(n : PLINT; x : PL_Float_Array; y : PL_Float_Array; code : PLINT); + pragma Import(C, plpoin, "c_plpoin"); + + + -- Draws a series of points in 3 space. + + procedure + plpoin3(n : PLINT; x : PL_Float_Array; y : PL_Float_Array; z : PL_Float_Array; code : PLINT); + pragma Import(C, plpoin3, "c_plpoin3"); + + + -- Draws a polygon in 3 space. + + procedure + plpoly3(n : PLINT; x : PL_Float_Array; y : PL_Float_Array; z : PL_Float_Array; draw : PL_Bool_Array; ifcc : PLBOOL); + pragma Import(C, plpoly3, "c_plpoly3"); + + + -- Set the floating point precision (in number of places) in numeric labels. + + procedure + plprec(setp : PLINT; prec : PLINT); + pragma Import(C, plprec, "c_plprec"); + + + -- Set fill pattern, using one of the predefined patterns. + + procedure + plpsty(patt : PLINT); + pragma Import(C, plpsty, "c_plpsty"); + + + -- Prints out "text" at world cooordinate (x,y). + + procedure + plptex(x : PLFLT; y : PLFLT; dx : PLFLT; dy : PLFLT; just : PLFLT; text : char_array); + pragma Import(C, plptex, "c_plptex"); + + + -- Replays contents of plot buffer to current device/file. + + procedure + plreplot; + pragma Import(C, plreplot, "c_plreplot"); + + + -- Set line color by red, green, blue from 0. to 1. + + procedure + plrgb(r : PLFLT; g : PLFLT; b : PLFLT); + pragma Import(C, plrgb, "c_plrgb"); + + + -- Set line color by 8 bit RGB values. + + procedure + plrgb1(r : PLINT; g : PLINT; b : PLINT); + pragma Import(C, plrgb1, "c_plrgb1"); + + + -- Functions for converting between HLS and RGB color space + + procedure + plrgbhls(r : PLFLT; g : PLFLT; b : PLFLT; p_h : out PLFLT; p_l : out PLFLT; p_s : out PLFLT); + pragma Import(C, plrgbhls, "c_plrgbhls"); + + + -- Set character height. + + procedure + plschr(def : PLFLT; scale : PLFLT); + pragma Import(C, plschr, "c_plschr"); + + + -- Set color map 0 colors by 8 bit RGB values + + procedure + plscmap0(r : PL_Integer_Array; g : PL_Integer_Array; b : PL_Integer_Array; ncol0 : PLINT); + pragma Import(C, plscmap0, "c_plscmap0"); + + + -- Set number of colors in cmap 0 + + procedure + plscmap0n(ncol0 : PLINT); + pragma Import(C, plscmap0n, "c_plscmap0n"); + + + -- Set color map 1 colors by 8 bit RGB values + + procedure + plscmap1(r : PL_Integer_Array; g : PL_Integer_Array; b : PL_Integer_Array; ncol1 : PLINT); + pragma Import(C, plscmap1, "c_plscmap1"); + + + -- Set color map 1 colors using a piece-wise linear relationship between + -- intensity [0,1] (cmap 1 index) and position in HLS or RGB color space. + + procedure + plscmap1l(itype : PLINT; npts : PLINT; intensity : PL_Float_Array; + coord1 : PL_Float_Array; coord2 : PL_Float_Array; coord3 : PL_Float_Array; + rev : PL_Bool_Array); + pragma Import(C, plscmap1l, "c_plscmap1l"); + + + -- Set number of colors in cmap 1 + + procedure + plscmap1n(ncol1 : PLINT); + pragma Import(C, plscmap1n, "c_plscmap1n"); + + + -- Set a given color from color map 0 by 8 bit RGB value + + procedure + plscol0(icol0 : PLINT; r : PLINT; g : PLINT; b : PLINT); + pragma Import(C, plscol0, "c_plscol0"); + + + -- Set the background color by 8 bit RGB value + + procedure + plscolbg(r : PLINT; g : PLINT; b : PLINT); + pragma Import(C, plscolbg, "c_plscolbg"); + + + -- Used to globally turn color output on/off + + procedure + plscolor(color : PLINT); + pragma Import(C, plscolor, "c_plscolor"); + + + -- Set the compression level + + procedure + plscompression(compression : PLINT); + pragma Import(C, plscompression, "c_plscompression"); + + + -- Set the device (keyword) name + + procedure + plsdev(devname : char_array); + pragma Import(C, plsdev, "c_plsdev"); + + + -- Set window into device space using margin, aspect ratio, and + -- justification + + procedure + plsdidev(mar : PLFLT; aspect : PLFLT; jx : PLFLT; jy : PLFLT); + pragma Import(C, plsdidev, "c_plsdidev"); + + + -- Set up transformation from metafile coordinates. + + procedure + plsdimap(dimxmin : PLINT; dimxmax : PLINT; dimymin : PLINT; dimymax : PLINT; + dimxpmm : PLFLT; dimypmm : PLFLT); + pragma Import(C, plsdimap, "c_plsdimap"); + + + -- Set plot orientation, specifying rotation in units of pi/2. + + procedure + plsdiori(rot : PLFLT); + pragma Import(C, plsdiori, "c_plsdiori"); + + + -- Set window into plot space + + procedure + plsdiplt(xmin : PLFLT; ymin : PLFLT; xmax : PLFLT; ymax : PLFLT); + pragma Import(C, plsdiplt, "c_plsdiplt"); + + + -- Set window into plot space incrementally (zoom) + + procedure + plsdiplz(xmin : PLFLT; ymin : PLFLT; xmax : PLFLT; ymax : PLFLT); + pragma Import(C, plsdiplz, "c_plsdiplz"); + + + -- Set the escape character for text strings. + + procedure + plsesc(esc : char); + pragma Import(C, plsesc, "c_plsesc"); + + + -- Set family file parameters + + procedure + plsfam(fam : PLINT; num : PLINT; bmax : PLINT); + pragma Import(C, plsfam, "c_plsfam"); + + + -- Set FCI (font characterization integer) + + procedure + plsfci(fci : PLUNICODE); + pragma Import(C, plsfci, "c_plsfci"); + + + -- Set the output file name. + + procedure + plsfnam(fnam : char_array); + pragma Import(C, plsfnam, "c_plsfnam"); + + + -- Shade region. + + procedure + plshade(a : Long_Float_Pointer_Array; nx : PLINT; ny : PLINT; defined : Mask_Function_Pointer_Type; + left : PLFLT; right : PLFLT; bottom : PLFLT; top : PLFLT; + shade_min : PLFLT; shade_max : PLFLT; + sh_cmap : PLINT; sh_color : PLFLT; sh_width : PLINT; + min_color : PLINT; min_width : PLINT; + max_color : PLINT; max_width : PLINT; + fill : Fill_Polygon_Procedure_Pointer_Type; rectangular : PLINT; + pltr : Transformation_Procedure_Pointer_Type; pltr_data : PLpointer); + pragma Import(C, plshade, "c_plshade"); + + + procedure + plshade1(a : Real_Matrix; nx : PLINT; ny : PLINT; defined : Mask_Function_Pointer_Type; + left : PLFLT; right : PLFLT; bottom : PLFLT; top : PLFLT; + shade_min : PLFLT; shade_max : PLFLT; + sh_cmap : PLINT; sh_color : PLFLT; sh_width : PLINT; + min_color : PLINT; min_width : PLINT; + max_color : PLINT; max_width : PLINT; + fill : Fill_Polygon_Procedure_Pointer_Type; rectangular : PLINT; + pltr : Transformation_Procedure_Pointer_Type; pltr_data : PLpointer); + pragma Import(C, plshade1, "c_plshade1"); + + + procedure + plshades( z : Long_Float_Pointer_Array; nx : PLINT; ny : PLINT; defined : Mask_Function_Pointer_Type; + xmin : PLFLT; xmax : PLFLT; ymin : PLFLT; ymax : PLFLT; + clevel : PL_Float_Array; nlevel : PLINT; fill_width : PLINT; + cont_color : PLINT; cont_width : PLINT; + fill : Fill_Polygon_Procedure_Pointer_Type; rectangular : PLINT; + pltr : Transformation_Procedure_Pointer_Type; pltr_data : PLpointer); + pragma Import(C, plshades, "c_plshades"); + + +-- fix this +-- procedure +-- plfshade(PLFLT (*f2eval) ( : PLINT; : PLINT; PLPointer), +-- PLPointer f2eval_data, +-- PLFLT (*c2eval) ( : PLINT; : PLINT; PLPointer), +-- PLPointer c2eval_data, +-- nx : PLINT; ny : PLINT; +-- left : PLFLT; right : PLFLT; bottom : PLFLT; top : PLFLT; +-- shade_min : PLFLT; shade_max : PLFLT; +-- sh_cmap : PLINT; sh_color : PLFLT; sh_width : PLINT; +-- min_color : PLINT; min_width : PLINT; +-- max_color : PLINT; max_width : PLINT; +-- void (*fill) ( : PLINT; : PL_Float_Array; : PL_Float_Array), rectangular : PLINT; +-- void (*pltr) ( : PLFLT; : PLFLT; : PL_Float_Array; : PL_Float_Array; PLPointer), +-- PLPointer pltr_data); +-- pragma Import(C, plfshade, "plfshade"); + + -- Set up lengths of major tick marks. + + procedure + plsmaj(def : PLFLT; scale : PLFLT); + pragma Import(C, plsmaj, "c_plsmaj"); + + + -- Set the memory area to be plotted (with the 'mem' driver) + + procedure + plsmem(maxx : PLINT; maxy : PLINT; plotmem : PLPointer); + pragma Import(C, plsmem, "c_plsmem"); + + + -- Set up lengths of minor tick marks. + + procedure + plsmin(def : PLFLT; scale : PLFLT); + pragma Import(C, plsmin, "c_plsmin"); + + + -- Set orientation. Must be done before calling plinit. + + procedure + plsori(ori : PLINT); + pragma Import(C, plsori, "c_plsori"); + + + -- Set output device parameters. Usually ignored by the driver. + + procedure + plspage(xp : PLFLT; yp : PLFLT; xleng : PLINT; yleng : PLINT; + xoff : PLINT; yoff : PLINT); + pragma Import(C, plspage, "c_plspage"); + + + -- Set the pause (on end-of-page) status + + procedure + plspause(pause : PLINT); + pragma Import(C, plspause, "c_plspause"); + + + -- Set stream number. + + procedure + plsstrm(strm : PLINT); + pragma Import(C, plsstrm, "c_plsstrm"); + + + -- Set the number of subwindows in x and y + + procedure + plssub(nx : PLINT; ny : PLINT); + pragma Import(C, plssub, "c_plssub"); + + + -- Set symbol height. + + procedure + plssym(def : PLFLT; scale : PLFLT); + pragma Import(C, plssym, "c_plssym"); + + + -- Initialize PLplot, passing in the windows/page settings. + + procedure + plstar(nx : PLINT; ny : PLINT); + pragma Import(C, plstar, "c_plstar"); + + + -- Initialize PLplot, passing the device name and windows/page settings. + + procedure + plstart(devname : char_array; nx : PLINT; ny : PLINT); + pragma Import(C, plstart, "c_plstart"); + + + -- Add a point to a stripchart. + + procedure + plstripa(id : PLINT; pen : PLINT; x : PLFLT; y : PLFLT); + pragma Import(C, plstripa, "c_plstripa"); + + + -- Create 1d stripchart + + procedure + plstripc(id : out PLINT; xspec : char_array; yspec : char_array; + xmin : PLFLT; xmax : PLFLT; xjump : PLFLT; ymin : PLFLT; ymax : PLFLT; + xlpos : PLFLT; ylpos : PLFLT; + y_ascl : PLBOOL; acc : PLBOOL; + colbox : PLINT; collab : PLINT; + colline : PL_Integer_Array; styline : PL_Integer_Array; legline : Stripchart_String_Array; + labx : char_array; laby : char_array; labtop : char_array); + pragma Import(C, plstripc, "c_plstripc"); + + + -- Deletes and releases memory used by a stripchart. + + procedure + plstripd(id : PLINT); + pragma Import(C, plstripd, "c_plstripd"); + + + -- plots a 2d image (or a matrix too large for plshade() ) + + procedure + plimage( data : Long_Float_Pointer_Array; nx : PLINT; ny : PLINT; + xmin : PLFLT; xmax : PLFLT; ymin : PLFLT; ymax : PLFLT; zmin : PLFLT; zmax : PLFLT; + Dxmin : PLFLT; Dxmax : PLFLT; Dymin : PLFLT; Dymax : PLFLT); + pragma Import(C, plimage, "plimage"); + + -- Set up a new line style + + procedure + plstyl(nms : PLINT; mark : PL_Integer_Array; space : PL_Integer_Array); + pragma Import(C, plstyl, "c_plstyl"); + + + -- Plots the 3d surface representation of the function z[x][y]. + + procedure + plsurf3d(x : PL_Float_Array; y : PL_Float_Array; z : Long_Float_Pointer_Array; nx : PLINT; ny : PLINT; + opt : PLINT; clevel : PL_Float_Array; nlevel : PLINT); + pragma Import(C, plsurf3d, "c_plsurf3d"); + + + -- Plots the 3d surface representation of the function z[x][y] with y + -- index limits. + + procedure + plsurf3dl(x : PL_Float_Array; y : PL_Float_Array; z : PL_Float_Array_2D; nx : PLINT; ny : PLINT; + opt : PLINT; clevel : PL_Float_Array; nlevel : PLINT; + ixstart : PLINT; ixn : PLINT; indexymin : out PLINT; indexymax : out PLINT); + pragma Import(C, plsurf3dl, "c_plsurf3dl"); + + + -- Sets the edges of the viewport to the specified absolute coordinates + + procedure + plsvpa(xmin : PLFLT; xmax : PLFLT; ymin : PLFLT; ymax : PLFLT); + pragma Import(C, plsvpa, "c_plsvpa"); + + + -- Set x axis labeling parameters + + procedure + plsxax(digmax : PLINT; field_digits : PLINT); -- "digits" changed to "field_digits". + pragma Import(C, plsxax, "c_plsxax"); + + + -- Set inferior X window + + procedure + plsxwin(window_id : PLINT); + pragma Import(C, plsxwin, "plsxwin"); + + -- Set y axis labeling parameters + + procedure + plsyax(digmax : PLINT; field_digits : PLINT); -- "digits" changed to "field_digits". + pragma Import(C, plsyax, "c_plsyax"); + + + -- Plots array y against x for n points using Hershey symbol "code" + + procedure + plsym(n : PLINT; x : PL_Float_Array; y : PL_Float_Array; code : PLINT); + pragma Import(C, plsym, "c_plsym"); + + + -- Set z axis labeling parameters + + procedure + plszax(digmax : PLINT; field_digits : PLINT); -- "digits" changed to "field_digits". + pragma Import(C, plszax, "c_plszax"); + + + -- Switches to text screen. + + procedure + pltext; + pragma Import(C, pltext, "c_pltext"); + + + -- Sets the edges of the viewport with the given aspect ratio, leaving + -- room for labels. + + procedure + plvasp(aspect : PLFLT); + pragma Import(C, plvasp, "c_plvasp"); + + + -- Creates the largest viewport of the specified aspect ratio that fits + -- within the specified norm... [truncated message content] |
From: <ai...@us...> - 2007-07-02 01:11:12
|
Revision: 7733 http://plplot.svn.sourceforge.net/plplot/?rev=7733&view=rev Author: airwin Date: 2007-07-01 18:11:14 -0700 (Sun, 01 Jul 2007) Log Message: ----------- Make file contents consistent with name change from plplotthin to plplot_thin form. Modified Paths: -------------- trunk/bindings/ada/plplot_thin.adb trunk/bindings/ada/plplot_thin.ads Modified: trunk/bindings/ada/plplot_thin.adb =================================================================== --- trunk/bindings/ada/plplot_thin.adb 2007-07-02 01:08:11 UTC (rev 7732) +++ trunk/bindings/ada/plplot_thin.adb 2007-07-02 01:11:14 UTC (rev 7733) @@ -1,7 +1,7 @@ with Ada.Text_IO; use Ada.Text_IO; -package body PLplotThin is +package body PLplot_Thin is -- Find minimum in a 1D array. function Vector_Min(x : Real_Vector) return Long_Float is @@ -184,4 +184,4 @@ plparseopts_local(Gnat_Argc_Access, Gnat_Argv, Mode); end plparseopts; -end PLplotThin; +end PLplot_Thin; Modified: trunk/bindings/ada/plplot_thin.ads =================================================================== --- trunk/bindings/ada/plplot_thin.ads 2007-07-02 01:08:11 UTC (rev 7732) +++ trunk/bindings/ada/plplot_thin.ads 2007-07-02 01:11:14 UTC (rev 7733) @@ -49,7 +49,7 @@ -- DEFINITIONS, FOR EXAMPLE, IF IT IS NOT ADA 2005 WITH ANNEX G.3 COMPLIANCE. --with Ada.Numerics.Long_Real_Arrays; use Ada.Numerics.Long_Real_Arrays; -package PLplotThin is +package PLplot_Thin is subtype PLINT is Integer; subtype PLFLT is Long_Float; PLfalse : constant Integer := 0; @@ -817,7 +817,7 @@ GRID_CSA : constant Integer := 1; -- Bivariate Cubic Spline approximation GRID_DTLI : constant Integer := 2; -- Delaunay Triangulation Linear Interpolation GRID_NNI : constant Integer := 3; -- Natural Neighbors Interpolation - GRID_NNIDW : constant Integer := 4;-- Nearest Neighbors Inverse Distance Weighted + GRID_NNIDW : constant Integer := 4; -- Nearest Neighbors Inverse Distance Weighted GRID_NNLI : constant Integer := 5; -- Nearest Neighbors Linear Interpolation GRID_NNAIDW : constant Integer := 6; -- Nearest Neighbors Around Inverse Distance Weighted @@ -1627,4 +1627,4 @@ pragma Import(C, pltr2, "pltr2"); -end PLplotThin; +end PLplot_Thin; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2007-07-02 01:19:15
|
Revision: 7734 http://plplot.svn.sourceforge.net/plplot/?rev=7734&view=rev Author: airwin Date: 2007-07-01 18:19:18 -0700 (Sun, 01 Jul 2007) Log Message: ----------- AWI for Jerry Bauck. Changes: Added the new binding files PLplot_Traditional.ads and PLplot_Traditional.adb. This binding is supposed to be exactly like the thick binding (PLplot.ads and PLplot.adb) except that the subprogram names are the traditional ones long used by PLplot's C API. If using PLplot_Traditional and at the same time accessing objects in PLplot_Thin, you will need to precede those names with PLplot_Thin. (note the .) (and do not "use" PLplot_Thin), as in PLplot_Thin.foo(bar) in order to avoid name collisions with the new binding. Removed the procedure Initialize_Plotter since it didn't do anything different than Initialize_PLplot; use Initialize_PLplot now. Renamed Plot_End to End_PLplot. Cleared up an unintentionally overloaded procedure name. The new name is Set_One_Color_Map_0 which had been Set_Color_Map_0 with four arguments. Replaced all occurrences of PLplotThin with PLplot_Thin. Modified Paths: -------------- trunk/bindings/ada/CMakeLists.txt trunk/bindings/ada/plplot.adb trunk/bindings/ada/plplot.ads Added Paths: ----------- trunk/bindings/ada/plplot_traditional.adb trunk/bindings/ada/plplot_traditional.ads Modified: trunk/bindings/ada/CMakeLists.txt =================================================================== --- trunk/bindings/ada/CMakeLists.txt 2007-07-02 01:11:14 UTC (rev 7733) +++ trunk/bindings/ada/CMakeLists.txt 2007-07-02 01:19:18 UTC (rev 7734) @@ -23,8 +23,10 @@ set(plplotada${LIB_TAG}_LIB_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/plplot.adb ${CMAKE_CURRENT_SOURCE_DIR}/plplot.ads - ${CMAKE_CURRENT_SOURCE_DIR}/plplotthin.adb - ${CMAKE_CURRENT_SOURCE_DIR}/plplotthin.ads + ${CMAKE_CURRENT_SOURCE_DIR}/plplot_thin.adb + ${CMAKE_CURRENT_SOURCE_DIR}/plplot_thin.ads + ${CMAKE_CURRENT_SOURCE_DIR}/plplot_traditional.adb + ${CMAKE_CURRENT_SOURCE_DIR}/plplot_traditional.ads ) add_library(plplotada${LIB_TAG} ${plplotada${LIB_TAG}_LIB_SRCS}) Modified: trunk/bindings/ada/plplot.adb =================================================================== --- trunk/bindings/ada/plplot.adb 2007-07-02 01:11:14 UTC (rev 7733) +++ trunk/bindings/ada/plplot.adb 2007-07-02 01:19:18 UTC (rev 7734) @@ -1,5 +1,5 @@ with - PLplotThin, + PLplot_Thin, Ada.Text_IO, Ada.Numerics.Long_Elementary_Functions, Ada.Strings.Unbounded, @@ -11,7 +11,7 @@ Interfaces.C.Pointers, Interfaces.C; use - PLplotThin, + PLplot_Thin, Ada.Text_IO, Ada.Numerics.Long_Elementary_Functions, Ada.Strings.Unbounded, @@ -27,20 +27,12 @@ -- High-Level subroutines for thick binding -- -------------------------------------------------------------------------------- - -- Initialization. Must be called before starting to plot. - -- Certain other procedures, if used, must be called first. - procedure Initialize_Plotter is - begin - Initialize_PLplot; - end Initialize_Plotter; - - -- When asked to draw white lines on black background, do it. -- This is the default. procedure Draw_White_On_Black is begin - Set_Color_Map_0(Black, 0, 0 , 0); - Set_Color_Map_0(White, 255, 255, 255); + Set_One_Color_Map_0(Black, 0, 0 , 0); + Set_One_Color_Map_0(White, 255, 255, 255); end Draw_White_On_Black; @@ -50,8 +42,8 @@ -- fix this Make a version that draws on white and converts _all_ colors to black for publications. procedure Draw_Black_On_White is begin - Set_Color_Map_0(Black, 255, 255, 255); - Set_Color_Map_0(White, 0, 0, 0); + Set_One_Color_Map_0(Black, 255, 255, 255); + Set_One_Color_Map_0(White, 0, 0, 0); end Draw_Black_On_White; @@ -557,7 +549,7 @@ end loop; -- Point to the do-nothing transformation procedure. - Transformation_Procedure_Pointer := plplotthin.pltr0'access; + Transformation_Procedure_Pointer := PLplot_Thin.pltr0'access; -- Fill the contour vector with some levels. Calculate_Contour_Levels(Contour_Levels, Matrix_Min(z), Matrix_Max(z)); @@ -958,10 +950,10 @@ -- Draw a 2D vector plot. -- plvect procedure Vector_Plot - (u, v : Real_Matrix; - Scale : Long_Float; + (u, v : Real_Matrix; + Scale : Long_Float; Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type; - Transformation_Data : Transformation_Data_Type) is + Transformation_Data : Transformation_Data_Type) is Transformation_Data_Address : PLpointer; begin @@ -1121,7 +1113,7 @@ -- plfcont: indices must satisfy 1 <= kx <= lx <= nx, aborting operation -- For now, only calls to pltr0 (no mapping) do not cause problems. --- plcont + -- plcont procedure Contour_Plot (z : Real_Matrix; x_Min_Index, x_Max_Index : Integer; @@ -1155,7 +1147,7 @@ -- by way of the f2eval_data pointer. This allows arbitrary organizations -- of 2d array data to be used. - -- plfcont + -- plfcont procedure Contour_Plot_Irregular_Data (Function_Evaluator_Pointer : Function_Evaluator_Pointer_Type; Irregular_Data : Real_Matrix; @@ -1222,18 +1214,18 @@ -- End a plotting session for all open streams. -- plend - procedure Plot_End is + procedure End_PLplot is begin plend; - end Plot_End; + end End_PLplot; -- End a plotting session for the current stream only. -- plend1 - procedure Plot_End_Current_Stream is + procedure End_PLplot_Current_Stream is begin plend1; - end Plot_End_Current_Stream; + end End_PLplot_Current_Stream; -- Simple interface for defining viewport and window. @@ -1490,8 +1482,8 @@ -- Get subpage boundaries in absolute coordinates - -- plgspa -- Results are millimeters from the lower left corner. + -- plgspa procedure Get_Subpage_Boundaries (Left_Edge, Right_Edge, Bottom_Edge, Top_Edge : out Long_Float) is begin @@ -1608,6 +1600,8 @@ end HLS_To_RGB; + -- Initialization. Must be called before starting plot. + -- Certain other procedures, if used, must be called first. -- Initializes PLplot, using preset or default options -- plinit procedure Initialize_PLplot is @@ -2023,12 +2017,12 @@ -- Set a given color from color map 0 by 8 bit RGB value -- plscol0 - procedure Set_Color_Map_0 + procedure Set_One_Color_Map_0 (Plot_Color : Plot_Color_Type; Red_Component, Green_Component, Blue_Component : Color_Component_Type) is begin plscol0(Plot_Color, Red_Component, Green_Component, Blue_Component); - end Set_Color_Map_0; + end Set_One_Color_Map_0; -- Set the background color by 8 bit RGB value @@ -2227,7 +2221,7 @@ end Shade_Region; - -- plshade1 + -- plshade1 procedure Shade_Region_1 (z : Real_Matrix; Mask_Function_Pointer : Mask_Function_Pointer_Type; @@ -2269,7 +2263,7 @@ end Shade_Region_1; - -- plshades + -- plshades procedure Shade_Regions (z : Real_Matrix; Mask_Function_Pointer : Mask_Function_Pointer_Type; @@ -2523,6 +2517,7 @@ -- This is an overloaded procedure equivalent to calling plstyl with its -- first argument zero. + -- plstyl procedure Set_Line_Style(Default_Continuous_Line : Integer) is Dummy_Marks, Dummy_Spaces : Integer_Array_1D(1 .. 1) := (others => 0); begin @@ -2560,7 +2555,8 @@ -- Set x axis labeling parameters - -- plsxax -- "digits" changed to "field_digits". + -- "digits" changed to "field_digits". + -- plsxax procedure Set_Floating_Point_Display_X(Max_Digits, Field_Digits : Integer) is begin plsxax(Max_Digits, Field_Digits); @@ -2577,7 +2573,8 @@ -- Set y axis labeling parameters - -- plsyax -- "digits" changed to "field_digits". + -- "digits" changed to "field_digits". + -- plsyax procedure Set_Floating_Point_Display_Y(Max_Digits, Field_Digits : Integer) is begin plsyax(Max_Digits, Field_Digits); @@ -2595,7 +2592,8 @@ -- Set z axis labeling parameters - -- plszax -- "digits" changed to "field_digits". + -- "digits" changed to "field_digits". + -- plszax procedure Set_Floating_Point_Display_Z(Max_Digits, Field_Digits : Integer) is begin plszax(Max_Digits, Field_Digits); @@ -2794,8 +2792,8 @@ -- NOTE: One would ordinarily call the initialization procedure at this point. -- However, PLplot has several optional procedures that, if used, must be - -- called _before_ the initializaiton, here called Initialize_Plotter. - -- Therefore, Initialize_Plotter MUST BE CALLED FROM THE USER'S PROGRAM, + -- called _before_ the initializaiton, here called Initialize_PLplot. + -- Therefore, Initialize_PLplot MUST BE CALLED FROM THE USER'S PROGRAM, -- before beginning normal plotting but AFTER any optional pre-initialization. -- The following lines are some examples of how the entire initialzation @@ -2807,12 +2805,12 @@ -- There should be a list of devices which use compression, and plscompression -- called conditioned on the current device being in that list. - -- Optionally call plsetopt (Set_Command_Line_Option) before Initialize_Plotter. + -- Optionally call plsetopt (Set_Command_Line_Option) before Initialize_PLplot. -- Parse_Command_Line_Arguments(1); -- Set_File_Family_Parameters(False); -- Default off; other args are don't-cares here. - -- Set_Orientation(Landscape); -- Optional; before Initialize_Plotter if used. + -- Set_Orientation(Landscape); -- Optional; before Initialize_PLplot if used. - -- Initialize_Plotter; + -- Initialize_PLplot; null; end PLplot; Modified: trunk/bindings/ada/plplot.ads =================================================================== --- trunk/bindings/ada/plplot.ads 2007-07-02 01:11:14 UTC (rev 7733) +++ trunk/bindings/ada/plplot.ads 2007-07-02 01:19:18 UTC (rev 7734) @@ -1,11 +1,11 @@ with - PLplotThin, + PLplot_Thin, System, Interfaces.C.Pointers, Ada.Strings.Unbounded, Ada.Strings.Maps; use - PLplotThin, + PLplot_Thin, Ada.Strings.Unbounded; -- COMMENT THIS LINE IF YOUR COMPILER DOES NOT INCLUDE THESE @@ -52,8 +52,10 @@ -- Arrays for various line appearances. type Color_Array_Type is array (1..Max_Lines_For_Multiplot) of Plot_Color_Type; Default_Color_Array : Color_Array_Type := (Red, Blue, Green, Salmon, BlueViolet); + type Line_Width_Array_Type is array (1..Max_Lines_For_Multiplot) of Integer; Default_Line_Width_Array : Line_Width_Array_Type := (1, 1, 1, 1, 1); + type Line_Style_Array_Type is array (1..Max_Lines_For_Multiplot) of Line_Style_Type; Default_Line_Style_Array : Line_Style_Array_Type := (1, 1, 1, 1, 1); @@ -145,11 +147,6 @@ -- High-Level subroutines for thick binding -- -------------------------------------------------------------------------------- - -- Initialization. Must be called before starting to plot. - -- Certain other procedures, if used, must be called first. - procedure Initialize_Plotter; - - -- When asked to draw white lines on black background, do it. -- This is the default. procedure Draw_White_On_Black; @@ -319,7 +316,8 @@ --------- Simple color table manipulatons ----- - type Color_Themes_For_Map_1_Type is (Gray, Blue_Green_Red, Red_Green_Blue, Red_Cyan_Blue, Blue_Black_Red, Red_Blue_Green, Red_Yellow); + type Color_Themes_For_Map_1_Type is (Gray, Blue_Green_Red, Red_Green_Blue, + Red_Cyan_Blue, Blue_Black_Red, Red_Blue_Green, Red_Yellow); -- Quick application of pre-fabricated color schemes to color map 1. @@ -366,9 +364,10 @@ Labels_Active : Boolean := False); + Next_Subpage : constant Integer := 0; + -- Advance to subpage "page", or to the next one if "page" = 0. -- pladv - Next_Subpage : constant Integer := 0; procedure Advance_To_Subpage(Page : Natural); @@ -380,10 +379,10 @@ -- Draw a 2D vector plot. -- plvect procedure Vector_Plot - (u, v : Real_Matrix; - Scale : Long_Float; + (u, v : Real_Matrix; + Scale : Long_Float; Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type; - Transformation_Data : Transformation_Data_Type); + Transformation_Data : Transformation_Data_Type); -- Set the style for the arrow used by plvect to plot vectors. -- plsvect @@ -473,8 +472,8 @@ procedure Set_Color_Map_1(Color : Long_Float_0_1_Type); - -- Draws a contour plot from data in f(nx,ny). Is just a front-end to - -- plfcont, with a particular choice for f2eval and f2eval_data. + -- Draws a contour plot from data in f(nx,ny). Is just a front-end to plfcont, + -- with a particular choice for f2eval and f2eval_data. -- plcont procedure Contour_Plot (z : Real_Matrix; @@ -529,12 +528,12 @@ -- End a plotting session for all open streams. -- plend - procedure Plot_End; + procedure End_PLplot; -- End a plotting session for the current stream only. -- plend1 - procedure Plot_End_Current_Stream; + procedure End_PLplot_Current_Stream; -- Simple interface for defining viewport and window. @@ -718,11 +717,12 @@ -- Get subpage boundaries in absolute coordinates + -- Results are millimeters from the lower left corner. -- plgspa - -- Results are millimeters from the lower left corner. procedure Get_Subpage_Boundaries (Left_Edge, Right_Edge, Bottom_Edge, Top_Edge : out Long_Float); + -- Get current stream number. -- plgstrm procedure Get_Stream_Number(Stream_Number : out Integer); @@ -790,6 +790,8 @@ Blue_Component : out Long_Float_0_1_Type); + -- Initialization. Must be called before starting plot. + -- Certain other procedures, if used, must be called first. -- Initializes PLplot, using preset or default options -- plinit procedure Initialize_PLplot; @@ -1044,6 +1046,7 @@ S_Or_B : Real_Vector; -- range 0.0 .. 1.0; not checked here Reverse_Hue : Boolean_Array_1D); -- False means red<->green<->blue<->red, True reverses + -- Set number of colors in cmap 1 -- plscmap1n procedure Set_Number_Of_Colors_In_Color_Map_1(Number_Of_Colors : Integer); @@ -1051,7 +1054,7 @@ -- Set a given color from color map 0 by 8 bit RGB value -- plscol0 - procedure Set_Color_Map_0 + procedure Set_One_Color_Map_0 (Plot_Color : Plot_Color_Type; Red_Component, Green_Component, Blue_Component : Color_Component_Type); @@ -1134,7 +1137,7 @@ -- Set FCI (font characterization integer) - -- plsfci; + -- plsfci procedure Set_Font_Characterization_Integer(Font_Characterization_Integer : PLUNICODE); -- Set the output file name. @@ -1319,9 +1322,11 @@ procedure Set_Line_Style(Marks, Spaces : Integer_Array_1D); + Default_Continuous_Line : constant Integer := 0; + -- This is an overloaded procedure equivalent to calling plstyl with its -- first argument zero. - Default_Continuous_Line : constant Integer := 0; + -- plstyl procedure Set_Line_Style(Default_Continuous_Line : Integer); @@ -1349,7 +1354,8 @@ -- Set x axis labeling parameters - -- plsxax -- "digits" changed to "field_digits". + -- "digits" changed to "field_digits". + -- plsxax procedure Set_Floating_Point_Display_X(Max_Digits, Field_Digits : Integer); @@ -1359,7 +1365,8 @@ -- Set y axis labeling parameters - -- plsyax -- "digits" changed to "field_digits". + -- "digits" changed to "field_digits". + -- plsyax procedure Set_Floating_Point_Display_Y(Max_Digits, Field_Digits : Integer); @@ -1371,7 +1378,8 @@ -- Set z axis labeling parameters - -- plszax -- "digits" changed to "field_digits". + -- "digits" changed to "field_digits". + -- plszax procedure Set_Floating_Point_Display_Z(Max_Digits, Field_Digits : Integer); Added: trunk/bindings/ada/plplot_traditional.adb =================================================================== --- trunk/bindings/ada/plplot_traditional.adb (rev 0) +++ trunk/bindings/ada/plplot_traditional.adb 2007-07-02 01:19:18 UTC (rev 7734) @@ -0,0 +1,2677 @@ +with + PLplot_Thin, + Ada.Text_IO, + Ada.Numerics.Long_Elementary_Functions, + Ada.Strings.Unbounded, + Ada.Unchecked_Conversion, + Ada.Strings.Maps, + Ada.Command_Line, + System, + System.Address_To_Access_Conversions, + Interfaces.C.Pointers, + Interfaces.C; +use + Ada.Text_IO, + Ada.Numerics.Long_Elementary_Functions, + Ada.Strings.Unbounded, + Interfaces.C; + +-- COMMENT THIS LINE IF YOUR COMPILER DOES NOT INCLUDE THESE +-- DEFINITIONS, FOR EXAMPLE, IF IT IS NOT ADA 2005 WITH ANNEX G.3 COMPLIANCE. +--with Ada.Numerics.Long_Real_Arrays; use Ada.Numerics.Long_Real_Arrays; + +package body PLplot_Traditional is + +-------------------------------------------------------------------------------- +-- High-Level subroutines for thick binding -- +-------------------------------------------------------------------------------- + + -- Initialization. Must be called before starting to plot. + -- Certain other procedures, if used, must be called first. + -- Removed June 26, 2007 as being redundant wrt Initialize_PLplot. +-- procedure Initialize_Plotter is +-- begin +-- Initialize_PLplot; +-- end Initialize_Plotter; + + + -- When asked to draw white lines on black background, do it. + -- This is the default. + procedure Draw_White_On_Black is + begin + plscol0(Black, 0, 0 , 0); + plscol0(White, 255, 255, 255); + end Draw_White_On_Black; + + + -- When asked to draw black lines on white background, reverse black and white. + -- This might look better on anti-aliased displays. + -- fix this Darken some colors which have low contrast on white background, e.g. Yellow. + -- fix this Make a version that draws on white and converts _all_ colors to black for publications. + procedure Draw_Black_On_White is + begin + plscol0(Black, 255, 255, 255); + plscol0(White, 0, 0, 0); + end Draw_Black_On_White; + + + -- Set default pen width. Docs don't say, so I'll make it 1. + -- I could make this depend on the type of outut device used. + Default_Pen_Width : constant Integer := 1; + procedure Set_Default_Pen_Width is + begin + plwid(Default_Pen_Width); + end Set_Default_Pen_Width; + + + -- Plotter for up to five x-y pairs and settable axis style, plot + -- line colors, widths, and styles, justification, zoom, and labels. + -- Can be used directly or as part of a "simple" plotter + -- such as those that follow or which are made by the user. + procedure Multiplot_Pairs + (x1 : Real_Vector := Dont_Plot_This; + y1 : Real_Vector := Dont_Plot_This; + x2 : Real_Vector := Dont_Plot_This; + y2 : Real_Vector := Dont_Plot_This; + x3 : Real_Vector := Dont_Plot_This; + y3 : Real_Vector := Dont_Plot_This; + x4 : Real_Vector := Dont_Plot_This; + y4 : Real_Vector := Dont_Plot_This; + x5 : Real_Vector := Dont_Plot_This; + y5 : Real_Vector := Dont_Plot_This; + X_Labels : Label_String_Array_Type := Default_Label_String_Array; + Y_Labels : Label_String_Array_Type := Default_Label_String_Array; + Title_Labels : Label_String_Array_Type := Default_Label_String_Array; + Axis_Style : Axis_Style_Type := Linear_Box_Plus; + Colors : Color_Array_Type := Default_Color_Array; + Line_Widths : Line_Width_Array_Type := Default_Line_Width_Array; + Line_Styles : Line_Style_Array_Type := Default_Line_Style_Array; + Justification : Justification_Type := Not_Justified; + x_Min_Zoom : Long_Float := Long_Float'small; + x_Max_Zoom : Long_Float := Long_Float'large; + y_Min_Zoom : Long_Float := Long_Float'small; + y_Max_Zoom : Long_Float := Long_Float'large) is + + x_Min, y_Min : Long_Float := Long_Float'large; + x_Max, y_Max : Long_Float := Long_Float'small; + + begin + -- Set or find x_Min. + if x_Min_Zoom /= Long_Float'small then -- zoom + x_Min := x_Min_Zoom; + else -- Auto-scale x_Min. + if x1'length /= 1 then + x_Min := Long_Float'min(x_Min, Vector_Min(x1)); + end if; + if x2'length /= 1 then + x_Min := Long_Float'min(x_Min, Vector_Min(x2)); + end if; + if x3'length /= 1 then + x_Min := Long_Float'min(x_Min, Vector_Min(x3)); + end if; + if x4'length /= 1 then + x_Min := Long_Float'min(x_Min, Vector_Min(x4)); + end if; + if x5'length /= 1 then + x_Min := Long_Float'min(x_Min, Vector_Min(x5)); + end if; + end if; -- Set or find x_Min. + + -- Set or find x_Max. + if x_Max_Zoom /= Long_Float'large then -- zoom + x_Max := x_Max_Zoom; + else -- Auto-scale x_Max. + if x1'length /= 1 then + x_Max := Long_Float'max(x_Max, Vector_Max(x1)); + end if; + if x2'length /= 1 then + x_Max := Long_Float'max(x_Max, Vector_Max(x2)); + end if; + if x3'length /= 1 then + x_Max := Long_Float'max(x_Max, Vector_Max(x3)); + end if; + if x4'length /= 1 then + x_Max := Long_Float'max(x_Max, Vector_Max(x4)); + end if; + if x5'length /= 1 then + x_Max := Long_Float'max(x_Max, Vector_Max(x5)); + end if; + end if; -- Set or find x_Max. + + -- Set or find y_Min. + if y_Min_Zoom /= Long_Float'small then -- zoom + y_Min := y_Min_Zoom; + else -- Auto-scale y_Min. + if y1'length /= 1 then + y_Min := Long_Float'min(y_Min, Vector_Min(y1)); + end if; + if y2'length /= 1 then + y_Min := Long_Float'min(y_Min, Vector_Min(y2)); + end if; + if y3'length /= 1 then + y_Min := Long_Float'min(y_Min, Vector_Min(y3)); + end if; + if y4'length /= 1 then + y_Min := Long_Float'min(y_Min, Vector_Min(y4)); + end if; + if y5'length /= 1 then + y_Min := Long_Float'min(y_Min, Vector_Min(y5)); + end if; + end if; -- Set or find y_Min. + + -- Set or find y_Max. + if y_Max_Zoom /= Long_Float'large then -- zoom + y_Max := y_Max_Zoom; + else -- Auto-scale y_Max. + if y1'length /= 1 then + y_Max := Long_Float'max(y_Max, Vector_Max(y1)); + end if; + if y2'length /= 1 then + y_Max := Long_Float'max(y_Max, Vector_Max(y2)); + end if; + if y3'length /= 1 then + y_Max := Long_Float'max(y_Max, Vector_Max(y3)); + end if; + if y4'length /= 1 then + y_Max := Long_Float'max(y_Max, Vector_Max(y4)); + end if; + if y5'length /= 1 then + y_Max := Long_Float'max(y_Max, Vector_Max(y5)); + end if; + end if; -- Set or find x_Max. + + + -- Set environment and its color. + plcol0(White); +-- Set_Environment_Clear_Subpage(x_Min, x_Max, y_Min, y_Max, Justification, Axis_Style); + plenv(x_Min, x_Max, y_Min, y_Max, Justification, Axis_Style); + + if x1'length /= 1 and y1'length /= 1 then + pllab(To_String(X_Labels(1)), To_String(Y_Labels(1)), To_String(Title_Labels(1))); + plcol0(Colors(1)); + --Set_Pen_Width(Line_Widths(1)); + pllsty(Line_Styles(1)); + plline(x1, y1); + end if; + + if x2'length /= 1 and y2'length /= 1 then + pllab(To_String(X_Labels(2)), To_String(Y_Labels(2)), To_String(Title_Labels(2))); + plcol0(Colors(2)); + --Set_Pen_Width(Line_Widths(2)); + pllsty(Line_Styles(2)); + plline(x2, y2); + end if; + + if x3'length /= 1 and y3'length /= 1 then + pllab(To_String(X_Labels(3)), To_String(Y_Labels(3)), To_String(Title_Labels(3))); + plcol0(Colors(3)); + --Set_Pen_Width(Line_Widths(3)); + pllsty(Line_Styles(3)); + plline(x3, y3); + end if; + + if x4'length /= 1 and y4'length /= 1 then + pllab(To_String(X_Labels(4)), To_String(Y_Labels(4)), To_String(Title_Labels(4))); + plcol0(Colors(4)); + --Set_Pen_Width(Line_Widths(4)); + pllsty(Line_Styles(4)); + plline(x4, y4); + end if; + + if x5'length /= 1 and y5'length /= 1 then + pllab(To_String(X_Labels(5)), To_String(Y_Labels(5)), To_String(Title_Labels(5))); + plcol0(Colors(5)); + --Set_Pen_Width(Line_Widths(5)); + pllsty(Line_Styles(5)); + plline(x5, y5); + end if; + + plcol0(White); + Set_Default_Pen_Width; + pllsty(1); --solid + end Multiplot_Pairs; + + +--------- Simple plotters requiring minimal arguments ----- + + + -- Simple plotter for single x array and multiple y arrays + procedure Simple_Plot + (x : Real_Vector; + y1 : Real_Vector := Dont_Plot_This; + y2 : Real_Vector := Dont_Plot_This; + y3 : Real_Vector := Dont_Plot_This; + y4 : Real_Vector := Dont_Plot_This; + y5 : Real_Vector := Dont_Plot_This; + X_Label : String := To_String(Default_Label_String); + Y_Label : String := To_String(Default_Label_String); + Title_Label : String := To_String(Default_Label_String)) is + + X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + + begin + X_Label_String_Array(1) := TUB(X_Label); -- First slot only; others not used. + Y_Label_String_Array(1) := TUB(Y_Label); -- First slot only; others not used. + Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. + + Multiplot_Pairs(x, y1, x, y2, x, y3, x, y4, x, y5, + X_Labels => X_Label_String_Array, + Y_Labels => Y_Label_String_Array, + Title_Labels => Title_Label_String_Array, + Axis_Style => Linear_Major_Grid); + end Simple_Plot; + + + -- Simple log x plotter for single x array and multiple y arrays + procedure Simple_Plot_Log_X + (x : Real_Vector; + y1 : Real_Vector := Dont_Plot_This; + y2 : Real_Vector := Dont_Plot_This; + y3 : Real_Vector := Dont_Plot_This; + y4 : Real_Vector := Dont_Plot_This; + y5 : Real_Vector := Dont_Plot_This; + X_Label : String := To_String(Default_Label_String); + Y_Label : String := To_String(Default_Label_String); + Title_Label : String := To_String(Default_Label_String)) is + + X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + + x_Log : Real_Vector(x'range); + + begin + X_Label_String_Array(1) := TUB(X_Label); -- First slot only; others not used. + Y_Label_String_Array(1) := TUB(Y_Label); -- First slot only; others not used. + Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. + + for i in x_Log'range loop + x_Log(i) := Log(x(i), 10.0); + end loop; + Multiplot_Pairs(x_Log, y1, x_Log, y2, x_Log, y3, x_Log, y4, x_Log, y5, + X_Labels => X_Label_String_Array, + Y_Labels => Y_Label_String_Array, + Title_Labels => Title_Label_String_Array, + Axis_Style => Log_X_Minor_Grid); + end Simple_Plot_Log_X; + + + -- Simple log y plotter for multiple x arrays and single y array + procedure Simple_Plot_Log_Y + (x1 : Real_Vector := Dont_Plot_This; + y : Real_Vector := Dont_Plot_This; -- Beware of argument order. + x2 : Real_Vector := Dont_Plot_This; + x3 : Real_Vector := Dont_Plot_This; + x4 : Real_Vector := Dont_Plot_This; + x5 : Real_Vector := Dont_Plot_This; + X_Label : String := To_String(Default_Label_String); + Y_Label : String := To_String(Default_Label_String); + Title_Label : String := To_String(Default_Label_String)) is + + X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + + y_Log : Real_Vector(y'range); + + begin + X_Label_String_Array(1) := TUB(X_Label); -- First slot only; others not used. + Y_Label_String_Array(1) := TUB(Y_Label); -- First slot only; others not used. + Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. + + for i in y_Log'range loop + y_Log(i) := Log(y(i), 10.0); + end loop; + Multiplot_Pairs(x1, y_Log, x2, y_Log, x3, y_Log, x4, y_Log, x5, y_Log, + X_Labels => X_Label_String_Array, + Y_Labels => Y_Label_String_Array, + Title_Labels => Title_Label_String_Array, + Axis_Style => Log_Y_Minor_Grid); + end Simple_Plot_Log_Y; + + + -- Simple log x - log y plotter + procedure Simple_Plot_Log_XY(x, y : Real_Vector; + X_Label : String := To_String(Default_Label_String); + Y_Label : String := To_String(Default_Label_String); + Title_Label : String := To_String(Default_Label_String)) is + + X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + + x_Log : Real_Vector(x'range); + y_Log : Real_Vector(y'range); + begin + X_Label_String_Array(1) := TUB(X_Label); -- First slot only; others not used. + Y_Label_String_Array(1) := TUB(Y_Label); -- First slot only; others not used. + Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. + + for i in x_Log'range loop + x_Log(i) := Log(x(i), 10.0); + y_Log(i) := Log(y(i), 10.0); + end loop; + Multiplot_Pairs(x_Log, y_Log, + X_Labels => X_Label_String_Array, + Y_Labels => Y_Label_String_Array, + Title_Labels => Title_Label_String_Array, + Axis_Style => Log_XY_Minor_Grid); + end Simple_Plot_Log_XY; + + + -- Simple plotter for multiple x-y arrays specified pairwise. + procedure Simple_Plot_Pairs + (x1 : Real_Vector := Dont_Plot_This; + y1 : Real_Vector := Dont_Plot_This; + x2 : Real_Vector := Dont_Plot_This; + y2 : Real_Vector := Dont_Plot_This; + x3 : Real_Vector := Dont_Plot_This; + y3 : Real_Vector := Dont_Plot_This; + x4 : Real_Vector := Dont_Plot_This; + y4 : Real_Vector := Dont_Plot_This; + x5 : Real_Vector := Dont_Plot_This; + y5 : Real_Vector := Dont_Plot_This; + X_Label : String := To_String(Default_Label_String); + Y_Label : String := To_String(Default_Label_String); + Title_Label : String := To_String(Default_Label_String)) is + + X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + begin + X_Label_String_Array(1) := TUB(X_Label); -- First slot only; others not used. + Y_Label_String_Array(1) := TUB(Y_Label); -- First slot only; others not used. + Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. + + Multiplot_Pairs(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, + X_Labels => X_Label_String_Array, + Y_Labels => Y_Label_String_Array, + Title_Labels => Title_Label_String_Array, + Axis_Style => Linear_Major_Grid); + end Simple_Plot_Pairs; + + +--------- Plotter requiring somewhat more arguments ------ + + -- Single plotter with flexible attributes + -- Similar to Multiplot_Pairs except single trace and no attribute arrays. + procedure Single_Plot + (x, y : Real_Vector; + X_Label : String := To_String(Default_Label_String); + Y_Label : String := To_String(Default_Label_String); + Title_Label : String := To_String(Default_Label_String); + Axis_Style : Axis_Style_Type := Linear_Major_Grid; + Color : Plot_Color_Type := Red; + Line_Width : Integer := 1; + Line_Style : Line_Style_Type := 1; + Justification : Justification_Type := Not_Justified; + x_Min_Zoom : Long_Float := Long_Float'small; + x_Max_Zoom : Long_Float := Long_Float'large; + y_Min_Zoom : Long_Float := Long_Float'small; + y_Max_Zoom : Long_Float := Long_Float'large) is + + X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; + Color_Array : Color_Array_Type := Default_Color_Array; + Line_Width_Array : Line_Width_Array_Type := Default_Line_Width_Array; + Line_Style_Array : Line_Style_Array_Type := Default_Line_Style_Array; + + begin + X_Label_String_Array(1) := TUB(X_Label); -- First slot only; others not used. + Y_Label_String_Array(1) := TUB(Y_Label); -- First slot only; others not used. + Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. + Color_Array(1) := Color; + Line_Width_Array(1) := Line_Width; -- First slot only; others not used. + Line_Style_Array(1) := Line_Style; -- First slot only; others not used. + + -- Process arrays if log plot is indicated. + -- The declare blocks save memory and time for non-log plots. + + -- Log x. + if Axis_Style in Log_X_Box_Plus..Log_X_Minor_Grid then + declare + x_Log : Real_Vector(x'range); + begin + for i in x_Log'range loop + x_Log(i) := Log(x(i), 10.0); + end loop; + + Multiplot_Pairs( + x_Log, y, + X_Labels => X_Label_String_Array, + Y_Labels => Y_Label_String_Array, + Title_Labels => Title_Label_String_Array, + Axis_Style => Axis_Style, + Colors => Color_Array, + Line_Widths => Line_Width_Array, + Line_Styles => Line_Style_Array, + Justification => Justification, + x_Min_Zoom => x_Min_Zoom, + x_Max_Zoom => x_Max_Zoom, + y_Min_Zoom => y_Min_Zoom, + y_Max_Zoom => y_Max_Zoom); + end; -- declare + end if; -- log x + + -- Log y + if Axis_Style in Log_Y_Box_Plus..Log_Y_Minor_Grid then + declare + y_Log : Real_Vector(y'range); + begin + for i in y_Log'range loop + y_Log(i) := Log(y(i), 10.0); + end loop; + Multiplot_Pairs( + x, y_Log, + X_Labels => X_Label_String_Array, + Y_Labels => Y_Label_String_Array, + Title_Labels => Title_Label_String_Array, + Axis_Style => Axis_Style, + Colors => Color_Array, + Line_Widths => Line_Width_Array, + Line_Styles => Line_Style_Array, + Justification => Justification, + x_Min_Zoom => x_Min_Zoom, + x_Max_Zoom => x_Max_Zoom, + y_Min_Zoom => y_Min_Zoom, + y_Max_Zoom => y_Max_Zoom); + end; -- declare + end if; -- log y + + -- Log x and log y + if Axis_Style in Log_XY_Box_Plus..Log_XY_Minor_Grid then + declare + x_Log : Real_Vector(x'range); + y_Log : Real_Vector(y'range); + begin + for i in x_Log'range loop + x_Log(i) := Log(x(i), 10.0); + y_Log(i) := Log(y(i), 10.0); + end loop; + Multiplot_Pairs( + x_Log, y_Log, + X_Labels => X_Label_String_Array, + Y_Labels => Y_Label_String_Array, + Title_Labels => Title_Label_String_Array, + Axis_Style => Axis_Style, + Colors => Color_Array, + Line_Widths => Line_Width_Array, + Line_Styles => Line_Style_Array, + Justification => Justification, + x_Min_Zoom => x_Min_Zoom, + x_Max_Zoom => x_Max_Zoom, + y_Min_Zoom => y_Min_Zoom, + y_Max_Zoom => y_Max_Zoom); + end; -- declare + end if; -- log x and log y + + -- Linear plot is indicated. + if Axis_Style in No_Box..Linear_Minor_Grid then + Multiplot_Pairs( + x, y, + X_Labels => X_Label_String_Array, + Y_Labels => Y_Label_String_Array, + Title_Labels => Title_Label_String_Array, + Axis_Style => Axis_Style, + Colors => Color_Array, + Line_Widths => Line_Width_Array, + Line_Styles => Line_Style_Array, + Justification => Justification, + x_Min_Zoom => x_Min_Zoom, + x_Max_Zoom => x_Max_Zoom, + y_Min_Zoom => y_Min_Zoom, + y_Max_Zoom => y_Max_Zoom); + end if; -- Linear plot + end Single_Plot; + + +--------- Simple Contour Plotter ------ + + -- Place-holder for the transformation data which is not used here. + Transformation_Data : aliased Transformation_Data_Type + (x_Length_Minus_1 => 2, y_Length_Minus_1 => 2, z_Length_Minus_1 => 2); + + procedure Simple_Contour + (z : Real_Matrix; + Number_Levels : Integer := 10; + X_Label : String := To_String(Default_Label_String); + Y_Label : String := To_String(Default_Label_String); + Title_Label : String := To_String(Default_Label_String)) is + + Contour_Levels : Real_Vector (0 .. Number_Levels); + Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type; + + begin + -- Fill up the dummy transformation data with something so we don't get warnings. + for i in Transformation_Data.xg'range loop -- use shorthand for .all on pointer + Transformation_Data.xg(i) := 0.0; + end loop; + for i in Transformation_Data.yg'range loop + Transformation_Data.yg(i) := 0.0; + end loop; + for i in Transformation_Data.zg'range loop + Transformation_Data.zg(i) := 0.0; + end loop; + + -- Point to the do-nothing transformation procedure. + Transformation_Procedure_Pointer := PLplot_Thin.pltr0'access; + + -- Fill the contour vector with some levels. + Calculate_Contour_Levels(Contour_Levels, Matrix_Min(z), Matrix_Max(z)); + + pladv(Next_Subpage); + plvpor(0.1, 0.9, 0.1, 0.9); + plwind(1.0, 35.0, 1.0, 46.0); -- fix + plcol0(White); + PLplot_Traditional.plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0); -- I have no idea why the compiler requires PLplot_Traditional. here. + plcol0(White); + pllab(X_Label, Y_Label, Title_Label); + plcol0(White); + pl_setcontlabelparam(0.008, 0.6, 0.1, True); + plcont(z, z'First(1), z'Last(1), z'First(2), z'Last(2), + Contour_Levels, Transformation_Procedure_Pointer, Transformation_Data); + end Simple_Contour; + + +--------- Simple 3D Mesh Plotter ------ + + procedure Simple_Mesh_3D + (x, y : Real_Vector; -- data definition points + z : Real_Matrix; -- z(x, y) = z(x(i), y(j)) + x_Min : Long_Float := 0.0; -- user coordinate limits + x_Max : Long_Float := 0.0; + y_Min : Long_Float := 0.0; + y_Max : Long_Float := 0.0; + Altitude : Long_Float := 30.0; -- viewing elevation angle in degrees + Azimuth : Long_Float := 30.0; -- viewing azimuth in degrees + X_Label : String := "x"; + Y_Label : String := "y"; + Z_Label : String := "z") is + + x_Min_Local, x_Max_Local, y_Min_Local, y_Max_Local : Long_Float; + + begin + -- Set min and max for x and y if they are not the defaults. + if x_Min = 0.0 and x_Max = 0.0 then -- override + x_Min_Local := Vector_Min(x); + x_Max_Local := Vector_Max(x); + else + x_Min_Local := x_Min; + x_Max_Local := x_Max; + end if; + + if y_Min = 0.0 and y_Max = 0.0 then -- override + y_Min_Local := Vector_Min(y); + y_Max_Local := Vector_Max(y); + else + y_Min_Local := y_Min; + y_Max_Local := y_Max; + end if; + + Quick_Set_Color_Map_1(Blue_Green_Red); -- no way to restore after doing this + pladv(Next_Subpage); + plcol0(White); + plvpor(0.0, 1.0, 0.0, 1.0); + plwind(-0.9, 0.9, -0.8, 1.5); + plw3d(1.0, 1.0, 1.0, x_Min_Local, x_Max_Local, y_Min_Local, y_Max_Local, + Matrix_Min(z), Matrix_Max(z), Altitude, Azimuth); -- plw3d + plbox3("bnstu", X_Label, 0.0, 0, + "bnstu", Y_Label, 0.0, 0, + "bcdmnstuv", Z_Label, 0.0, 0); -- plbox3 + plmesh(x, y, z, Lines_Parallel_To_X_And_Y + Magnitude_Color); -- plmesh + end Simple_Mesh_3D; + + +--------- Simple 3D Surface Plotter ------ + + procedure Simple_Surface_3D + (x, y : Real_Vector; -- data definition points + z : Real_Matrix; -- z(x, y) = z(x(i), y(j)) + x_Min : Long_Float := 0.0; -- user coordinate limits + x_Max : Long_Float := 0.0; + y_Min : Long_Float := 0.0; + y_Max : Long_Float := 0.0; + Altitude : Long_Float := 30.0; -- viewing elevation angle in degrees + Azimuth : Long_Float := 30.0; -- viewing azimuth in degrees + X_Label : String := "x"; + Y_Label : String := "y"; + Z_Label : String := "z") is + + x_Min_Local, x_Max_Local, y_Min_Local, y_Max_Local : Long_Float; + Contour_Levels_Dummy : Real_Vector(0..1) := (others => 0.0); + + begin + -- Set min and max for x and y if they are not the defaults. + if x_Min = 0.0 and x_Max = 0.0 then -- override + x_Min_Local := Vector_Min(x); + x_Max_Local := Vector_Max(x); + else + x_Min_Local := x_Min; + x_Max_Local := x_Max; + end if; + + if y_Min = 0.0 and y_Max = 0.0 then -- override + y_Min_Local := Vector_Min(y); + y_Max_Local := Vector_Max(y); + else + y_Min_Local := y_Min; + y_Max_Local := y_Max; + end if; + + Quick_Set_Color_Map_1(Blue_Green_Red); -- no way to restore after doing this + pladv(Next_Subpage); + plcol0(White); + plvpor(0.0, 1.0, 0.0, 1.0); + plwind(-0.9, 0.9, -0.8, 1.5); + plw3d(1.0, 1.0, 1.0, x_Min_Local, x_Max_Local, y_Min_Local, y_Max_Local, + Matrix_Min(z), Matrix_Max(z), Altitude, Azimuth); -- plw3d + plbox3("bnstu", X_Label, 0.0, 0, + "bnstu", Y_Label, 0.0, 0, + "bcdmnstuv", Z_Label, 0.0, 0); -- plbox3 + plmesh(x, y, z, Lines_Parallel_To_X_And_Y + Magnitude_Color); -- plmesh + plsurf3d(x, y, z, Magnitude_Color, Contour_Levels_Dummy); + end Simple_Surface_3D; + + + +--------- Simple color table manipulatons ----- + + -- Quick application of pre-fabricated color schemes to color map 1. + procedure Quick_Set_Color_Map_1(Color_Theme : Color_Themes_For_Map_1_Type) is + + Controls_3 : Real_Vector (0..2); -- 3 control points + Controls_4 : Real_Vector (0..3); -- 4 control points + Red_3, Green_3, Blue_3 : Real_Vector (0..2); -- define 3 + Red_4, Green_4, Blue_4 : Real_Vector (0..3); -- define 4 + Hue_3, Lightness_3, Saturation_3 : Real_Vector (0..2); -- define 3 + Hue_4, Lightness_4, Saturation_4 : Real_Vector (0..3); -- define 4 + Reverse_Hue_3 : Boolean_Array_1D (0..2); + Reverse_Hue_4 : Boolean_Array_1D (0..3); + begin + plscmap1n(256); + + Controls_3(0) := 0.0; + Controls_3(1) := 0.5; + Controls_3(2) := 1.0; + + Controls_4(0) := 0.0; + Controls_4(1) := 0.5; -- allow a "bend" at the mid-point + Controls_4(2) := 0.5; -- allow a "bend" at the mid-point + Controls_4(3) := 1.0; + + -- Initialize everything, even unused stuff. + Red_3(0) := 0.0; + Red_3(1) := 0.0; + Red_3(2) := 0.0; + Green_3(0) := 0.0; + Green_3(1) := 0.0; + Green_3(2) := 0.0; + Blue_3(0) := 0.0; + Blue_3(1) := 0.0; + Blue_3(2) := 0.0; + + Red_4(0) := 0.0; + Red_4(1) := 0.0; + Red_4(2) := 0.0; + Red_4(3) := 0.0; + Green_4(0) := 0.0; + Green_4(1) := 0.0; + Green_4(2) := 0.0; + Green_4(3) := 0.0; + Blue_4(0) := 0.0; + Blue_4(1) := 0.0; + Blue_4(2) := 0.0; + Blue_4(3) := 0.0; + + Hue_3(0) := 0.0; + Hue_3(1) := 0.0; + Hue_3(2) := 0.0; + Lightness_3(0) := 0.0; + Lightness_3(1) := 0.0; + Lightness_3(2) := 0.0; + Saturation_3(0) := 0.0; + Saturation_3(1) := 0.0; + Saturation_3(2) := 0.0; + + Hue_4(0) := 0.0; + Hue_4(1) := 0.0; + Hue_4(2) := 0.0; + Hue_4(3) := 0.0; + Lightness_4(0) := 0.0; + Lightness_4(1) := 0.0; + Lightness_4(2) := 0.0; + Lightness_4(3) := 0.0; + Saturation_4(0) := 0.0; + Saturation_4(1) := 0.0; + Saturation_4(2) := 0.0; + Saturation_4(3) := 0.0; + + case Color_Theme is + when Gray => + begin + Hue_3(0) := 0.0; + Hue_3(1) := 0.0; + Hue_3(2) := 0.0; + Lightness_3(0) := 0.0; + Lightness_3(1) := 0.5; + Lightness_3(2) := 1.0; + Saturation_3(0) := 0.0; + Saturation_3(1) := 0.0; + Saturation_3(2) := 0.0; + Reverse_Hue_3(0) := False; + Reverse_Hue_3(1) := False; + Reverse_Hue_3(2) := False; + plscmap1l(HLS, Controls_3, Hue_3, Lightness_3, Saturation_3, Reverse_Hue_3); + end; + when Blue_Green_Red => + begin + Blue_3(0) := 1.0; + Blue_3(1) := 0.0; + Blue_3(2) := 0.0; + Green_3(0) := 0.0; + Green_3(1) := 1.0; + Green_3(2) := 0.0; + Red_3(0) := 0.0; + Red_3(1) := 0.0; + Red_3(2) := 1.0; + Reverse_Hue_3(0) := False; + Reverse_Hue_3(1) := False; + Reverse_Hue_3(2) := False; + plscmap1l(RGB, Controls_3, Red_3, Green_3, Blue_3, Reverse_Hue_3); + end; + when Red_Green_Blue => + begin + Blue_3(0) := 0.0; + Blue_3(1) := 0.0; + Blue_3(2) := 1.0; + Green_3(0) := 0.0; + Green_3(1) := 1.0; + Green_3(2) := 0.0; + Red_3(0) := 1.0; + Red_3(1) := 0.0; + Red_3(2) := 0.0; + Reverse_Hue_3(0) := False; + Reverse_Hue_3(1) := False; + Reverse_Hue_3(2) := False; + plscmap1l(RGB, Controls_3, Red_3, Green_3, Blue_3, Reverse_Hue_3); + end; + when Red_Cyan_Blue => + begin + Hue_3(0) := 360.0; + Hue_3(1) := 300.0; + Hue_3(2) := 240.0; + Saturation_3(0) := 1.0; + Saturation_3(1) := 1.0; + Saturation_3(2) := 1.0; + Lightness_3(0) := 0.5; + Lightness_3(1) := 0.5; + Lightness_3(2) := 0.5; + Reverse_Hue_3(0) := False; + Reverse_Hue_3(1) := False; + Reverse_Hue_3(2) := False; + plscmap1l(HLS, Controls_3, Hue_3, Lightness_3, Saturation_3, Reverse_Hue_3); + end; + when Blue_Black_Red => + begin + Hue_4(0) := 240.0; -- Blue + Hue_4(1) := 240.0; -- Blue + Hue_4(2) := 0.0; -- Red + Hue_4(3) := 0.0; -- Red + Saturation_4(0) := 1.0; + Saturation_4(1) := 1.0; + Saturation_4(2) := 1.0; + Saturation_4(3) := 1.0; + Lightness_4(0) := 0.5; -- Apparently different from Brightness + Lightness_4(1) := 0.0; + Lightness_4(2) := 0.0; + Lightness_4(3) := 0.5; + Reverse_Hue_4(0) := False; + Reverse_Hue_4(1) := False; + Reverse_Hue_4(2) := False; + Reverse_Hue_4(3) := False; + plscmap1l(HLS, Controls_4, Hue_4, Lightness_4, Saturation_4, Reverse_Hue_4); + end; + when Red_Blue_Green => + begin + Hue_3(0) := 360.0; -- red + Hue_3(1) := 210.0; -- blue + Hue_3(2) := 120.0; -- green + Lightness_3(0) := 0.5; + Lightness_3(1) := 0.5; + Lightness_3(2) := 0.5; + Saturation_3(0) := 1.0; + Saturation_3(1) := 1.0; + Saturation_3(2) := 1.0; + Reverse_Hue_3(0) := False; + Reverse_Hue_3(1) := False; + Reverse_Hue_3(2) := False; + plscmap1l(HLS, Controls_3, Hue_3, Lightness_3, Saturation_3, Reverse_Hue_3); + end; + when Red_Yellow => + begin + Hue_3(0) := 0.0; -- red + Hue_3(1) := 30.0; -- orange + Hue_3(2) := 60.0; -- yellow + Lightness_3(0) := 0.5; + Lightness_3(1) := 0.5; + Lightness_3(2) := 0.5; + Saturation_3(0) := 1.0; + Saturation_3(1) := 1.0; + Saturation_3(2) := 1.0; + Reverse_Hue_3(0) := False; + Reverse_Hue_3(1) := False; + Reverse_Hue_3(2) := False; + plscmap1l(HLS, Controls_3, Hue_3, Lightness_3, Saturation_3, Reverse_Hue_3); + end; + end case; + end Quick_Set_Color_Map_1; + + +-------------------------------------------------------------------------------- +-- Auxiliary things -- +-------------------------------------------------------------------------------- + + -- This is a mask function for Shade_Regions (aka plshades) et al that always + -- returns 1 so that all points are plotted. Can be used as a template + -- for other user-written mask functions. This behave the same as + -- when passing null for the second argument in Shade_Regions. + function Mask_Function_No_Mask(x, y : Long_Float) return Integer is + begin + return 1; + end Mask_Function_No_Mask; + + + -- Given an array to hold contour levels and function minimum and maximum, + -- fill it and return. Useful for contour and shade plots. + procedure Calculate_Contour_Levels + (Contour_Levels : in out Real_Vector; + z_Min, z_Max : Long_Float) is + + step : Long_Float; + ii : Integer; + begin + step := (z_Max - z_Min) / Long_Float(Contour_Levels'Last - Contour_Levels'First); + for i in Contour_Levels'range loop + ii := i - Contour_Levels'First; -- reference back to 0. + Contour_Levels(i) := z_Min + step * Long_Float(ii); + end loop; + end Calculate_Contour_Levels; + + +-------------------------------------------------------------------------------- +-- Re-define PLplot procedures using Ada style. -- +-------------------------------------------------------------------------------- + +-- These correspond to the section in plot.h called "Function Prototypes". + + -- set the format of the contour labels + procedure pl_setcontlabelformat + (Limit_Exponent : Integer := 4; + Significant_Digits : Integer := 2) is + begin + PLplot_Thin.pl_setcontlabelformat(Limit_Exponent, Significant_Digits); + end pl_setcontlabelformat; + + + -- set offset and spacing of contour labels + procedure pl_setcontlabelparam + (Label_Offset : Long_Float := 0.006; -- Units are ??? + Label_Font_Height : Long_Float := 0.3; -- Units are ??? + Label_Spacing : Long_Float := 0.1; -- Units are??? + Labels_Active : Boolean := False) is + + active : Integer; + + begin + if Labels_Active then + active := 1; + else + active := 0; + end if; + PLplot_Thin.pl_setcontlabelparam(Label_Offset, Label_Font_Height, Label_Spacing, active); + end pl_setcontlabelparam; + + + -- Advance to subpage "page", or to the next one if "page" = 0. + procedure pladv(Page : Natural) is + begin + PLplot_Thin.pladv(Page); + end pladv; + + + -- fix this + -- simple arrow plotter. + procedure plarrows is + begin + Put_Line("Not implemented due to lack of documentation."); + end plarrows; + + + -- fix this See comment for plcont. + -- Draw a 2D vector plot. + procedure plvect + (u, v : Real_Matrix; + Scale : Long_Float; + Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type; + Transformation_Data : Transformation_Data_Type) is + + Transformation_Data_Address : PLpointer; + begin + Transformation_Data_Address := Transformation_Data'Address; + PLplot_Thin.plvect(Matrix_To_Pointers(u), Matrix_To_Pointers(v), u'Length(1), u'Length(2), Scale, Transformation_Procedure_Pointer, Transformation_Data_Address); + end plvect; + + + -- Set the style for the arrow used by plvect to plot vectors. + procedure plsvect + (X_Vertices, Y_Vertices : Real_Vector; -- Should be range -0.5..0.5 + Fill_Arrow : Boolean) is + + fill : PLBOOL; + + begin + if Fill_Arrow then + fill := PLtrue; + else + fill := PLfalse; + end if; + PLplot_Thin.plsvect(X_Vertices, Y_Vertices, X_Vertices'length, fill); + end plsvect; + + + -- This functions similarly to plbox() except that the origin of the axes + -- is placed at the user-specified point (x0, y0). + procedure plaxes + (X_Origin, Y_Origin : Long_Float; + X_Option_String : String; + X_Major_Tick_Interval : Long_Float; + X_Number_Of_Subintervals : Natural; + Y_Option_String : String; + Y_Major_Tick_Interval : Long_Float; + Y_Number_Of_Subintervals : Natural) is + begin + PLplot_Thin.plaxes + (X_Origin, Y_Origin, + To_C(X_Option_String, True), X_Major_Tick_Interval, X_Number_Of_Subintervals, + To_C(Y_Option_String, True), Y_Major_Tick_Interval, Y_Number_Of_Subintervals); + end plaxes; + + + -- Plot a histogram using x to store data values and y to store frequencies + procedure plbin + (Bin_Values : Real_Vector; -- "x" + Bin_Counts : Real_Vector; -- "y" + Options : Integer) is -- Options are not defined in plplot.h. + begin + PLplot_Thin.plbin(Bin_Values'length, Bin_Values, Bin_Counts, Options); + end plbin; + + + -- Start new page. Should only be used with pleop(). + procedure plbop is + begin + PLplot_Thin.plbop; + end plbop; + + + -- This draws a box around the current viewport. + procedure plbox + (X_Option_String : String; + X_Major_Tick_Interval : Long_Float; + X_Number_Of_Subintervals : Natural := 0; + Y_Option_String : String; + Y_Major_Tick_Interval : Long_Float; + Y_Number_Of_Subintervals : Natural) is + begin + PLplot_Thin.plbox + (To_C(X_Option_String, True), X_Major_Tick_Interval, X_Number_Of_Subintervals, + To_C(Y_Option_String, True), Y_Major_Tick_Interval, Y_Number_Of_Subintervals); + end plbox; + + + -- This is the 3-d a... [truncated message content] |
From: <ai...@us...> - 2007-07-05 01:07:29
|
Revision: 7746 http://plplot.svn.sourceforge.net/plplot/?rev=7746&view=rev Author: airwin Date: 2007-07-04 18:05:07 -0700 (Wed, 04 Jul 2007) Log Message: ----------- Maximum of 16 cmap0 colours is too conservative. Change to 256. Modified Paths: -------------- trunk/bindings/ada/plplot.ads trunk/bindings/ada/plplot_traditional.ads Modified: trunk/bindings/ada/plplot.ads =================================================================== --- trunk/bindings/ada/plplot.ads 2007-07-04 20:51:51 UTC (rev 7745) +++ trunk/bindings/ada/plplot.ads 2007-07-05 01:05:07 UTC (rev 7746) @@ -29,7 +29,7 @@ -- color map has been changed, then these colors will return surprising -- results. Color map 0 can always be restored to its default state using -- Restore_Default_Snapshot_Of_Color_Map_0. - subtype Plot_Color_Type is Integer range 0..15; + subtype Plot_Color_Type is Integer range 0..255; Black : constant Plot_Color_Type := 0; Red : constant Plot_Color_Type := 1; Yellow : constant Plot_Color_Type := 2; Modified: trunk/bindings/ada/plplot_traditional.ads =================================================================== --- trunk/bindings/ada/plplot_traditional.ads 2007-07-04 20:51:51 UTC (rev 7745) +++ trunk/bindings/ada/plplot_traditional.ads 2007-07-05 01:05:07 UTC (rev 7746) @@ -29,7 +29,7 @@ -- colors map has been changed, then these colors will return surprising -- results. Color map 0 can always be restored to its default state using -- Set_Color_Map_0( - subtype Plot_Color_Type is Integer range 0..15; + subtype Plot_Color_Type is Integer range 0..255; Black : constant Plot_Color_Type := 0; Red : constant Plot_Color_Type := 1; Yellow : constant Plot_Color_Type := 2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2007-07-17 15:33:32
|
Revision: 7751 http://plplot.svn.sourceforge.net/plplot/?rev=7751&view=rev Author: airwin Date: 2007-07-17 08:33:34 -0700 (Tue, 17 Jul 2007) Log Message: ----------- AWI for Jerry Bauck. Removed restricted range of Plot_Color_Type in the bindings. Modified Paths: -------------- trunk/bindings/ada/plplot.ads trunk/bindings/ada/plplot_traditional.ads Modified: trunk/bindings/ada/plplot.ads =================================================================== --- trunk/bindings/ada/plplot.ads 2007-07-16 16:42:28 UTC (rev 7750) +++ trunk/bindings/ada/plplot.ads 2007-07-17 15:33:34 UTC (rev 7751) @@ -29,7 +29,7 @@ -- color map has been changed, then these colors will return surprising -- results. Color map 0 can always be restored to its default state using -- Restore_Default_Snapshot_Of_Color_Map_0. - subtype Plot_Color_Type is Integer range 0..255; + subtype Plot_Color_Type is Integer; Black : constant Plot_Color_Type := 0; Red : constant Plot_Color_Type := 1; Yellow : constant Plot_Color_Type := 2; Modified: trunk/bindings/ada/plplot_traditional.ads =================================================================== --- trunk/bindings/ada/plplot_traditional.ads 2007-07-16 16:42:28 UTC (rev 7750) +++ trunk/bindings/ada/plplot_traditional.ads 2007-07-17 15:33:34 UTC (rev 7751) @@ -29,7 +29,7 @@ -- colors map has been changed, then these colors will return surprising -- results. Color map 0 can always be restored to its default state using -- Set_Color_Map_0( - subtype Plot_Color_Type is Integer range 0..255; + subtype Plot_Color_Type is Integer; Black : constant Plot_Color_Type := 0; Red : constant Plot_Color_Type := 1; Yellow : constant Plot_Color_Type := 2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2007-08-15 23:02:26
|
Revision: 7803 http://plplot.svn.sourceforge.net/plplot/?rev=7803&view=rev Author: airwin Date: 2007-08-15 16:02:28 -0700 (Wed, 15 Aug 2007) Log Message: ----------- AWI for Jerry Bauck. Clean up and improve comments. Add an optional with-use clause to plplot_auxiliary.ads to accommodate compiling with or without Ada 2005 Annex G.3. Make "simple log" plotters accept optional arbitrary log base. Default is 10.0 which value was previously hardwired. Callers can be unmodified since the new argument is the last argument in the list. Modified Paths: -------------- trunk/bindings/ada/plplot.adb trunk/bindings/ada/plplot.ads trunk/bindings/ada/plplot_auxiliary.ads trunk/bindings/ada/plplot_traditional.adb trunk/bindings/ada/plplot_traditional.ads Modified: trunk/bindings/ada/plplot.adb =================================================================== --- trunk/bindings/ada/plplot.adb 2007-08-15 19:16:53 UTC (rev 7802) +++ trunk/bindings/ada/plplot.adb 2007-08-15 23:02:28 UTC (rev 7803) @@ -183,7 +183,6 @@ if x1'length /= 1 and y1'length /= 1 then Write_Labels(To_String(X_Labels(1)), To_String(Y_Labels(1)), To_String(Title_Labels(1))); Set_Pen_Color(Colors(1)); - --Set_Pen_Width(Line_Widths(1)); Select_Line_Style(Line_Styles(1)); Draw_Curve(x1, y1); end if; @@ -191,7 +190,6 @@ if x2'length /= 1 and y2'length /= 1 then Write_Labels(To_String(X_Labels(2)), To_String(Y_Labels(2)), To_String(Title_Labels(2))); Set_Pen_Color(Colors(2)); - --Set_Pen_Width(Line_Widths(2)); Select_Line_Style(Line_Styles(2)); Draw_Curve(x2, y2); end if; @@ -199,7 +197,6 @@ if x3'length /= 1 and y3'length /= 1 then Write_Labels(To_String(X_Labels(3)), To_String(Y_Labels(3)), To_String(Title_Labels(3))); Set_Pen_Color(Colors(3)); - --Set_Pen_Width(Line_Widths(3)); Select_Line_Style(Line_Styles(3)); Draw_Curve(x3, y3); end if; @@ -207,7 +204,6 @@ if x4'length /= 1 and y4'length /= 1 then Write_Labels(To_String(X_Labels(4)), To_String(Y_Labels(4)), To_String(Title_Labels(4))); Set_Pen_Color(Colors(4)); - --Set_Pen_Width(Line_Widths(4)); Select_Line_Style(Line_Styles(4)); Draw_Curve(x4, y4); end if; @@ -215,7 +211,6 @@ if x5'length /= 1 and y5'length /= 1 then Write_Labels(To_String(X_Labels(5)), To_String(Y_Labels(5)), To_String(Title_Labels(5))); Set_Pen_Color(Colors(5)); - --Set_Pen_Width(Line_Widths(5)); Select_Line_Style(Line_Styles(5)); Draw_Curve(x5, y5); end if; @@ -259,6 +254,8 @@ -- Simple log x plotter for single x array and multiple y arrays + -- fix this: Automatically skip zero-valued abscissa; place marker at the + -- left-hand side of the plot at the ordinate of the deleted point. procedure Simple_Plot_Log_X (x : Real_Vector; y1 : Real_Vector := Dont_Plot_This; @@ -268,7 +265,8 @@ y5 : Real_Vector := Dont_Plot_This; X_Label : String := To_String(Default_Label_String); Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String)) is + Title_Label : String := To_String(Default_Label_String); + Log_Base : Long_Float := 10.0) is -- Should this default to e? X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; @@ -282,7 +280,7 @@ Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. for i in x_Log'range loop - x_Log(i) := Log(x(i), 10.0); + x_Log(i) := Log(x(i), Log_Base); end loop; Multiplot_Pairs(x_Log, y1, x_Log, y2, x_Log, y3, x_Log, y4, x_Log, y5, X_Labels => X_Label_String_Array, @@ -293,6 +291,8 @@ -- Simple log y plotter for multiple x arrays and single y array + -- fix this: Automatically skip zero-valued ordinate; place marker at the + -- bottom of the plot at the abscissa of the deleted point. procedure Simple_Plot_Log_Y (x1 : Real_Vector := Dont_Plot_This; y : Real_Vector := Dont_Plot_This; -- Beware of argument order. @@ -302,7 +302,8 @@ x5 : Real_Vector := Dont_Plot_This; X_Label : String := To_String(Default_Label_String); Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String)) is + Title_Label : String := To_String(Default_Label_String); + Log_Base : Long_Float := 10.0) is -- Should this default to e? X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; @@ -316,7 +317,7 @@ Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. for i in y_Log'range loop - y_Log(i) := Log(y(i), 10.0); + y_Log(i) := Log(y(i), Log_Base); end loop; Multiplot_Pairs(x1, y_Log, x2, y_Log, x3, y_Log, x4, y_Log, x5, y_Log, X_Labels => X_Label_String_Array, @@ -327,10 +328,12 @@ -- Simple log x - log y plotter - procedure Simple_Plot_Log_XY(x, y : Real_Vector; + procedure Simple_Plot_Log_XY + (x, y : Real_Vector; X_Label : String := To_String(Default_Label_String); Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String)) is + Title_Label : String := To_String(Default_Label_String); + x_Log_Base, y_Log_Base : Long_Float := 10.0) is -- Should this default to e? X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; @@ -344,8 +347,8 @@ Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. for i in x_Log'range loop - x_Log(i) := Log(x(i), 10.0); - y_Log(i) := Log(y(i), 10.0); + x_Log(i) := Log(x(i), x_Log_Base); + y_Log(i) := Log(y(i), y_Log_Base); end loop; Multiplot_Pairs(x_Log, y_Log, X_Labels => X_Label_String_Array, Modified: trunk/bindings/ada/plplot.ads =================================================================== --- trunk/bindings/ada/plplot.ads 2007-08-15 19:16:53 UTC (rev 7802) +++ trunk/bindings/ada/plplot.ads 2007-08-15 23:02:28 UTC (rev 7803) @@ -22,7 +22,7 @@ -- Default dummy arrays for various plotters which take multiple inputs. subtype Length_One_Real_Vector is Real_Vector(1..1); - Dont_Plot_This : Length_One_Real_Vector := (1..1 => 0.0); + Dont_Plot_This : Length_One_Real_Vector := (1..1 => Long_Float'small); -- Default colors for Color Map 0. -- These are hard-wired to the current colors of color map 0; if that @@ -289,7 +289,8 @@ y5 : Real_Vector := Dont_Plot_This; X_Label : String := To_String(Default_Label_String); Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String)); + Title_Label : String := To_String(Default_Label_String); + Log_Base : Long_Float := 10.0); -- Should this default to e? -- Simple log y plotter for multiple x arrays and single y array @@ -302,14 +303,17 @@ x5 : Real_Vector := Dont_Plot_This; X_Label : String := To_String(Default_Label_String); Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String)); + Title_Label : String := To_String(Default_Label_String); + Log_Base : Long_Float := 10.0); -- Should this default to e? -- Simple log x - log y plotter - procedure Simple_Plot_Log_XY(x, y : Real_Vector; + procedure Simple_Plot_Log_XY + (x, y : Real_Vector; X_Label : String := To_String(Default_Label_String); Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String)); + Title_Label : String := To_String(Default_Label_String); + x_Log_Base, y_Log_Base : Long_Float := 10.0); -- Should this default to e? -- Simple plotter for multiple x-y arrays specified pairwise. Modified: trunk/bindings/ada/plplot_auxiliary.ads =================================================================== --- trunk/bindings/ada/plplot_auxiliary.ads 2007-08-15 19:16:53 UTC (rev 7802) +++ trunk/bindings/ada/plplot_auxiliary.ads 2007-08-15 23:02:28 UTC (rev 7803) @@ -8,21 +8,22 @@ package PLplot_Auxiliary is +-- COMMENT THIS LINE IF YOUR COMPILER DOES NOT INCLUDE THESE +-- DEFINITIONS, FOR EXAMPLE, IF IT IS NOT ADA 2005 WITH ANNEX G.3 COMPLIANCE. +--with Ada.Numerics.Long_Real_Arrays; use Ada.Numerics.Long_Real_Arrays; + -------------------------------------------------------------------------------- -- Utility type declarations used by the bindings -- -------------------------------------------------------------------------------- - -- UN-COMMENT THESE TWO LINES IF YOUR COMPILER DOES NOT INCLUDE THESE + -- UN-COMMENT THE NEXT TWO LINES IF YOUR COMPILER DOES NOT INCLUDE THESE -- DEFINITIONS, FOR EXAMPLE, IF IT IS NOT ADA 2005 WITH ANNEX G.3 COMPLIANCE. -- COMMENT THESE TWO LINES IF YOUR COMPILER DECLARES SIMILAR TYPES (E.G. IT - -- IS ADA 2005 WITH ANNEX G.3) IN THAT CASE, YOU WILL NEED TO ADD A LINE - -- LIKE THIS SOMEWHERE: - -- with Ada.Numerics.Long_Real_Arrays; use Ada.Numerics.Long_Real_Arrays; + -- IS ADA 2005 WITH ANNEX G.3) -- ALSO, YOU WILL NEED TO MAKE A SINGLE-LINE EDIT TO THESE BINDING FILES: -- plplot.ads, plplot.adb, plplot_traditional.ads, plplot_traditional.adb, -- and plplot_thin.ads. - -- type Real_Vector is array (Integer range <>) of Long_Float; type Real_Matrix is array (Integer range <>, Integer range <>) of Long_Float; Modified: trunk/bindings/ada/plplot_traditional.adb =================================================================== --- trunk/bindings/ada/plplot_traditional.adb 2007-08-15 19:16:53 UTC (rev 7802) +++ trunk/bindings/ada/plplot_traditional.adb 2007-08-15 23:02:28 UTC (rev 7803) @@ -258,6 +258,8 @@ -- Simple log x plotter for single x array and multiple y arrays + -- fix this: Automatically skip zero-valued abscissa; place marker at the + -- left-hand side of the plot at the ordinate of the deleted point. procedure Simple_Plot_Log_X (x : Real_Vector; y1 : Real_Vector := Dont_Plot_This; @@ -267,7 +269,8 @@ y5 : Real_Vector := Dont_Plot_This; X_Label : String := To_String(Default_Label_String); Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String)) is + Title_Label : String := To_String(Default_Label_String); + Log_Base : Long_Float := 10.0) is -- Should this default to e? X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; @@ -281,7 +284,7 @@ Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. for i in x_Log'range loop - x_Log(i) := Log(x(i), 10.0); + x_Log(i) := Log(x(i), Log_Base); end loop; Multiplot_Pairs(x_Log, y1, x_Log, y2, x_Log, y3, x_Log, y4, x_Log, y5, X_Labels => X_Label_String_Array, @@ -292,6 +295,8 @@ -- Simple log y plotter for multiple x arrays and single y array + -- fix this: Automatically skip zero-valued ordinate; place marker at the + -- bottom of the plot at the abscissa of the deleted point. procedure Simple_Plot_Log_Y (x1 : Real_Vector := Dont_Plot_This; y : Real_Vector := Dont_Plot_This; -- Beware of argument order. @@ -301,7 +306,8 @@ x5 : Real_Vector := Dont_Plot_This; X_Label : String := To_String(Default_Label_String); Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String)) is + Title_Label : String := To_String(Default_Label_String); + Log_Base : Long_Float := 10.0) is -- Should this default to e? X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; @@ -315,7 +321,7 @@ Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. for i in y_Log'range loop - y_Log(i) := Log(y(i), 10.0); + y_Log(i) := Log(y(i), Log_Base); end loop; Multiplot_Pairs(x1, y_Log, x2, y_Log, x3, y_Log, x4, y_Log, x5, y_Log, X_Labels => X_Label_String_Array, @@ -326,10 +332,12 @@ -- Simple log x - log y plotter - procedure Simple_Plot_Log_XY(x, y : Real_Vector; + procedure Simple_Plot_Log_XY + (x, y : Real_Vector; X_Label : String := To_String(Default_Label_String); Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String)) is + Title_Label : String := To_String(Default_Label_String); + x_Log_Base, y_Log_Base : Long_Float := 10.0) is -- Should this default to e? X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; @@ -343,8 +351,8 @@ Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. for i in x_Log'range loop - x_Log(i) := Log(x(i), 10.0); - y_Log(i) := Log(y(i), 10.0); + x_Log(i) := Log(x(i), x_Log_Base); + y_Log(i) := Log(y(i), y_Log_Base); end loop; Multiplot_Pairs(x_Log, y_Log, X_Labels => X_Label_String_Array, Modified: trunk/bindings/ada/plplot_traditional.ads =================================================================== --- trunk/bindings/ada/plplot_traditional.ads 2007-08-15 19:16:53 UTC (rev 7802) +++ trunk/bindings/ada/plplot_traditional.ads 2007-08-15 23:02:28 UTC (rev 7803) @@ -22,7 +22,7 @@ -- Default dummy arrays for various plotters which take multiple inputs. subtype Length_One_Real_Vector is Real_Vector(1..1); - Dont_Plot_This : Length_One_Real_Vector := (1..1 => 0.0); + Dont_Plot_This : Length_One_Real_Vector := (1..1 => Long_Float'small); -- Default colors for Color Map 0. -- These are hard-wired to the current colors of color map 0; if that @@ -288,7 +288,8 @@ y5 : Real_Vector := Dont_Plot_This; X_Label : String := To_String(Default_Label_String); Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String)); + Title_Label : String := To_String(Default_Label_String); + Log_Base : Long_Float := 10.0); -- Should this default to e? -- Simple log y plotter for multiple x arrays and single y array @@ -301,14 +302,17 @@ x5 : Real_Vector := Dont_Plot_This; X_Label : String := To_String(Default_Label_String); Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String)); + Title_Label : String := To_String(Default_Label_String); + Log_Base : Long_Float := 10.0); -- Should this default to e? -- Simple log x - log y plotter - procedure Simple_Plot_Log_XY(x, y : Real_Vector; + procedure Simple_Plot_Log_XY + (x, y : Real_Vector; X_Label : String := To_String(Default_Label_String); Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String)); + Title_Label : String := To_String(Default_Label_String); + x_Log_Base, y_Log_Base : Long_Float := 10.0); -- Should this default to e? -- Simple plotter for multiple x-y arrays specified pairwise. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2007-09-22 17:50:16
|
Revision: 7880 http://plplot.svn.sourceforge.net/plplot/?rev=7880&view=rev Author: airwin Date: 2007-09-22 10:50:20 -0700 (Sat, 22 Sep 2007) Log Message: ----------- AWI for Jerry Bauck. Added proper front matter to all files. Added some constants relating to histogram and bin options, passed via the argument called opt in both cases. They are in the C API but I must have missed them before. Also removed the constraint on a justification parameter for text drawing that had been constrained to be between 0.0 and 1.0. Modified Paths: -------------- trunk/bindings/ada/plplot.adb trunk/bindings/ada/plplot.ads trunk/bindings/ada/plplot_auxiliary.adb trunk/bindings/ada/plplot_auxiliary.ads trunk/bindings/ada/plplot_thin.adb trunk/bindings/ada/plplot_thin.ads trunk/bindings/ada/plplot_traditional.adb trunk/bindings/ada/plplot_traditional.ads Property Changed: ---------------- trunk/bindings/ada/plplot_auxiliary.adb trunk/bindings/ada/plplot_auxiliary.ads trunk/bindings/ada/plplot_traditional.adb trunk/bindings/ada/plplot_traditional.ads Modified: trunk/bindings/ada/plplot.adb =================================================================== --- trunk/bindings/ada/plplot.adb 2007-09-22 15:34:18 UTC (rev 7879) +++ trunk/bindings/ada/plplot.adb 2007-09-22 17:50:20 UTC (rev 7880) @@ -1,3 +1,25 @@ +-- $Id$ + +-- Thick Ada binding to PLplot + +-- Copyright (C) 2006-2007 Jerry Bauck + +-- This file is part of PLplot. + +-- PLplot is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Library Public License as published +-- by the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. + +-- PLplot 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 Library General Public License for more details. + +-- You should have received a copy of the GNU Library General Public License +-- along with PLplot; if not, write to the Free Software +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + with PLplot_Thin, PLplot_Auxiliary, @@ -2028,7 +2050,7 @@ procedure Write_Text_World (x, y : Long_Float; Delta_X, Delta_Y : Long_Float; - Justification : Long_Float_0_1_Type; + Justification : Long_Float; The_Text : String) is begin plptex(x, y, Delta_X, Delta_Y, Justification, To_C(The_Text, True)); Modified: trunk/bindings/ada/plplot.ads =================================================================== --- trunk/bindings/ada/plplot.ads 2007-09-22 15:34:18 UTC (rev 7879) +++ trunk/bindings/ada/plplot.ads 2007-09-22 17:50:20 UTC (rev 7880) @@ -1,3 +1,25 @@ +-- $Id$ + +-- Thick Ada binding to PLplot + +-- Copyright (C) 2006-2007 Jerry Bauck + +-- This file is part of PLplot. + +-- PLplot is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Library Public License as published +-- by the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. + +-- PLplot 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 Library General Public License for more details. + +-- You should have received a copy of the GNU Library General Public License +-- along with PLplot; if not, write to the Free Software +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + with PLplot_Thin, PLplot_Auxiliary, @@ -210,8 +232,24 @@ GRID_NNIDW : constant Gridding_Algorithm_Type := 4; GRID_NNLI : constant Gridding_Algorithm_Type := 5; GRID_NNAIDW : constant Gridding_Algorithm_Type := 6; +-------------------------------------------------------------------------------- + -- Flags for the opt argument in plhist -- + Histogram_Default : constant Integer := 0; + Histogram_Noscaling : constant Integer := 1; + Histogram_Ignore_Outliers : constant Integer := 2; + Histogram_Noexpand : constant Integer := 8; + Histogram_Noempty : constant Integer := 16; + + + -- Flags for the opt argument in plbin -- + Bin_Default : constant Integer := 0; + Bin_Centred : constant Integer := 1; + Bin_Noexpand : constant Integer := 2; + Bin_Noempty : constant Integer := 4; + + -------------------------------------------------------------------------------- -- A convenient string function -- -------------------------------------------------------------------------------- @@ -1098,7 +1136,7 @@ procedure Write_Text_World (x, y : Long_Float; Delta_X, Delta_Y : Long_Float; - Justification : Long_Float_0_1_Type; + Justification : Long_Float; The_Text : String); Modified: trunk/bindings/ada/plplot_auxiliary.adb =================================================================== --- trunk/bindings/ada/plplot_auxiliary.adb 2007-09-22 15:34:18 UTC (rev 7879) +++ trunk/bindings/ada/plplot_auxiliary.adb 2007-09-22 17:50:20 UTC (rev 7880) @@ -1,3 +1,26 @@ +-- $Id$ + +-- Auxiliary types and subprograms to be with-ed by all the Ada +-- bindings to PLplot + +-- Copyright (C) 2006-2007 Jerry Bauck + +-- This file is part of PLplot. + +-- PLplot is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Library Public License as published +-- by the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. + +-- PLplot 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 Library General Public License for more details. + +-- You should have received a copy of the GNU Library General Public License +-- along with PLplot; if not, write to the Free Software +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + package body PLplot_Auxiliary is -------------------------------------------------------------------------------- Property changes on: trunk/bindings/ada/plplot_auxiliary.adb ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Modified: trunk/bindings/ada/plplot_auxiliary.ads =================================================================== --- trunk/bindings/ada/plplot_auxiliary.ads 2007-09-22 15:34:18 UTC (rev 7879) +++ trunk/bindings/ada/plplot_auxiliary.ads 2007-09-22 17:50:20 UTC (rev 7880) @@ -1,3 +1,26 @@ +-- $Id$ + +-- Auxiliary types and subprograms to be with-ed and by all the Ada +-- bindings to PLplot + +-- Copyright (C) 2006-2007 Jerry Bauck + +-- This file is part of PLplot. + +-- PLplot is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Library Public License as published +-- by the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. + +-- PLplot 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 Library General Public License for more details. + +-- You should have received a copy of the GNU Library General Public License +-- along with PLplot; if not, write to the Free Software +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + with Ada.Strings.Bounded, Ada.Strings.Unbounded; Property changes on: trunk/bindings/ada/plplot_auxiliary.ads ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Modified: trunk/bindings/ada/plplot_thin.adb =================================================================== --- trunk/bindings/ada/plplot_thin.adb 2007-09-22 15:34:18 UTC (rev 7879) +++ trunk/bindings/ada/plplot_thin.adb 2007-09-22 17:50:20 UTC (rev 7880) @@ -1,3 +1,25 @@ +-- $Id$ + +-- Thin Ada binding to PLplot + +-- Copyright (C) 2006-2007 Jerry Bauck + +-- This file is part of PLplot. + +-- PLplot is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Library Public License as published +-- by the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. + +-- PLplot 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 Library General Public License for more details. + +-- You should have received a copy of the GNU Library General Public License +-- along with PLplot; if not, write to the Free Software +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + with PLplot_Auxiliary; use Modified: trunk/bindings/ada/plplot_thin.ads =================================================================== --- trunk/bindings/ada/plplot_thin.ads 2007-09-22 15:34:18 UTC (rev 7879) +++ trunk/bindings/ada/plplot_thin.ads 2007-09-22 17:50:20 UTC (rev 7880) @@ -1,27 +1,27 @@ - -- Copyright (C) 1992 Maurice J. LeBrun, Geoff Furnish, Tony Richardson. - -- Copyright (C) 2004 Alan W. Irwin - -- Copyright (C) 2004 Rafael Laboissiere - -- Copyright (C) 2004 Andrew Ross +-- $Id$ - -- This file is part of PLplot. +-- Thin Ada binding to PLplot - -- PLplot is free software; you can redistribute it and/or modify - -- it under the terms of the GNU Library General Public License as published - -- by the Free Software Foundation; either version 2 of the License, or - -- (at your option) any later version. +-- Copyright (C) 2006-2007 Jerry Bauck - -- PLplot 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 Library General Public License for more details. +-- This file is part of PLplot. - -- You should have received a copy of the GNU Library General Public License - -- along with PLplot; if not, write to the Free Software - -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +-- PLplot is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Library Public License as published +-- by the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. - ---------------------------------------------------------------------------- - +-- PLplot 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 Library General Public License for more details. +-- You should have received a copy of the GNU Library General Public License +-- along with PLplot; if not, write to the Free Software +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +-------------------------------------------------------------------------------- + -- SOME NOTES ABOUT THE ADA BINDINGS (JB) -- Some C-arguments of the form PLINT *a are supposed to point at 8-bit unsigned chars -- and are said to carry information out of the function, according to the PLplot docs. @@ -451,6 +451,12 @@ -- Plot a histogram using x to store data values and y to store frequencies + -- Flags for the opt argument in plbin + PL_Bin_Default : constant Integer := 0; + PL_Bin_Centred : constant Integer := 1; + PL_Bin_Noexpand : constant Integer := 2; + PL_Bin_Noempty : constant Integer := 4; + procedure plbin(nbin : PLINT; x : PL_Float_Array; y : PL_Float_Array; center : PLINT); pragma Import(C, plbin, "c_plbin"); @@ -833,6 +839,13 @@ -- Draws a histogram of n values of a variable in array data[0..n-1] + -- Flags for the opt argument in plhist + PL_Hist_Default : constant Integer := 0; + PL_Hist_Noscaling : constant Integer := 1; + PL_Hist_Ignore_Outliers : constant Integer := 2; + PL_Hist_Noexpand : constant Integer := 8; + PL_Hist_Noempty : constant Integer := 16; + procedure plhist(n : PLINT; data : PL_Float_Array; datmin : PLFLT; datmax : PLFLT; nbin : PLINT; oldwin : PLINT); Modified: trunk/bindings/ada/plplot_traditional.adb =================================================================== --- trunk/bindings/ada/plplot_traditional.adb 2007-09-22 15:34:18 UTC (rev 7879) +++ trunk/bindings/ada/plplot_traditional.adb 2007-09-22 17:50:20 UTC (rev 7880) @@ -1,3 +1,25 @@ +-- $Id$ + +-- Ada binding to PLplot using the traditional PLplot subprogram names + +-- Copyright (C) 2006-2007 Jerry Bauck + +-- This file is part of PLplot. + +-- PLplot is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Library Public License as published +-- by the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. + +-- PLplot 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 Library General Public License for more details. + +-- You should have received a copy of the GNU Library General Public License +-- along with PLplot; if not, write to the Free Software +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + with PLplot_Thin, PLplot_Auxiliary, @@ -1950,7 +1972,7 @@ procedure plptex (x, y : Long_Float; Delta_X, Delta_Y : Long_Float; - Justification : Long_Float_0_1_Type; + Justification : Long_Float; The_Text : String) is begin PLplot_Thin.plptex(x, y, Delta_X, Delta_Y, Justification, To_C(The_Text, True)); Property changes on: trunk/bindings/ada/plplot_traditional.adb ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Modified: trunk/bindings/ada/plplot_traditional.ads =================================================================== --- trunk/bindings/ada/plplot_traditional.ads 2007-09-22 15:34:18 UTC (rev 7879) +++ trunk/bindings/ada/plplot_traditional.ads 2007-09-22 17:50:20 UTC (rev 7880) @@ -1,3 +1,25 @@ +-- $Id$ + +-- Ada binding to PLplot using the traditional PLplot subprogram names + +-- Copyright (C) 2006-2007 Jerry Bauck + +-- This file is part of PLplot. + +-- PLplot is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Library Public License as published +-- by the Free Software Foundation; either version 2 of the License, or +-- (at your option) any later version. + +-- PLplot 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 Library General Public License for more details. + +-- You should have received a copy of the GNU Library General Public License +-- along with PLplot; if not, write to the Free Software +-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + with PLplot_Thin, PLplot_Auxiliary, @@ -209,8 +231,24 @@ GRID_NNIDW : constant Gridding_Algorithm_Type := 4; GRID_NNLI : constant Gridding_Algorithm_Type := 5; GRID_NNAIDW : constant Gridding_Algorithm_Type := 6; +-------------------------------------------------------------------------------- + -- Flags for the opt argument in plhist -- + Histogram_Default : constant Integer := 0; + Histogram_Noscaling : constant Integer := 1; + Histogram_Ignore_Outliers : constant Integer := 2; + Histogram_Noexpand : constant Integer := 8; + Histogram_Noempty : constant Integer := 16; + + + -- Flags for the opt argument in plbin -- + Bin_Default : constant Integer := 0; + Bin_Centred : constant Integer := 1; + Bin_Noexpand : constant Integer := 2; + Bin_Noempty : constant Integer := 4; + + -------------------------------------------------------------------------------- -- A convenient string function -- -------------------------------------------------------------------------------- @@ -1012,7 +1050,7 @@ procedure plptex (x, y : Long_Float; Delta_X, Delta_Y : Long_Float; - Justification : Long_Float_0_1_Type; + Justification : Long_Float; The_Text : String); Property changes on: trunk/bindings/ada/plplot_traditional.ads ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2007-09-26 18:51:35
|
Revision: 7889 http://plplot.svn.sourceforge.net/plplot/?rev=7889&view=rev Author: airwin Date: 2007-09-26 11:51:38 -0700 (Wed, 26 Sep 2007) Log Message: ----------- AWI for JB. Tweak of front matter. Modified Paths: -------------- trunk/bindings/ada/plplot_auxiliary.adb trunk/bindings/ada/plplot_auxiliary.ads trunk/bindings/ada/plplot_thin.adb trunk/bindings/ada/plplot_thin.ads Modified: trunk/bindings/ada/plplot_auxiliary.adb =================================================================== --- trunk/bindings/ada/plplot_auxiliary.adb 2007-09-25 18:13:08 UTC (rev 7888) +++ trunk/bindings/ada/plplot_auxiliary.adb 2007-09-26 18:51:38 UTC (rev 7889) @@ -3,7 +3,7 @@ -- Auxiliary types and subprograms to be with-ed by all the Ada -- bindings to PLplot --- Copyright (C) 2006-2007 Jerry Bauck +-- Copyright (C) 2006-2007 Jerry Bauck -- This file is part of PLplot. Modified: trunk/bindings/ada/plplot_auxiliary.ads =================================================================== --- trunk/bindings/ada/plplot_auxiliary.ads 2007-09-25 18:13:08 UTC (rev 7888) +++ trunk/bindings/ada/plplot_auxiliary.ads 2007-09-26 18:51:38 UTC (rev 7889) @@ -3,7 +3,7 @@ -- Auxiliary types and subprograms to be with-ed and by all the Ada -- bindings to PLplot --- Copyright (C) 2006-2007 Jerry Bauck +-- Copyright (C) 2006-2007 Jerry Bauck -- This file is part of PLplot. Modified: trunk/bindings/ada/plplot_thin.adb =================================================================== --- trunk/bindings/ada/plplot_thin.adb 2007-09-25 18:13:08 UTC (rev 7888) +++ trunk/bindings/ada/plplot_thin.adb 2007-09-26 18:51:38 UTC (rev 7889) @@ -2,7 +2,7 @@ -- Thin Ada binding to PLplot --- Copyright (C) 2006-2007 Jerry Bauck +-- Copyright (C) 2006-2007 Jerry Bauck -- This file is part of PLplot. Modified: trunk/bindings/ada/plplot_thin.ads =================================================================== --- trunk/bindings/ada/plplot_thin.ads 2007-09-25 18:13:08 UTC (rev 7888) +++ trunk/bindings/ada/plplot_thin.ads 2007-09-26 18:51:38 UTC (rev 7889) @@ -2,7 +2,7 @@ -- Thin Ada binding to PLplot --- Copyright (C) 2006-2007 Jerry Bauck +-- Copyright (C) 2006-2007 Jerry Bauck -- This file is part of PLplot. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2007-09-26 18:53:36
|
Revision: 7890 http://plplot.svn.sourceforge.net/plplot/?rev=7890&view=rev Author: airwin Date: 2007-09-26 11:53:39 -0700 (Wed, 26 Sep 2007) Log Message: ----------- AWI for JB. Removed the constraint from text-positioning parameters Justification, x_Legend_Position, y_Legend_Position. They were constrained to be between 0.0 and 1.0 as indicated in the documentation but now they are just Long_Float so that text positions outside the nominal range are allowed. Modified Paths: -------------- trunk/bindings/ada/plplot.adb trunk/bindings/ada/plplot.ads trunk/bindings/ada/plplot_traditional.adb trunk/bindings/ada/plplot_traditional.ads Modified: trunk/bindings/ada/plplot.adb =================================================================== --- trunk/bindings/ada/plplot.adb 2007-09-26 18:51:38 UTC (rev 7889) +++ trunk/bindings/ada/plplot.adb 2007-09-26 18:53:39 UTC (rev 7890) @@ -2,7 +2,7 @@ -- Thick Ada binding to PLplot --- Copyright (C) 2006-2007 Jerry Bauck +-- Copyright (C) 2006-2007 Jerry Bauck -- This file is part of PLplot. @@ -1909,7 +1909,7 @@ (Side : String; Position_From_Edge : Long_Float; Position_Along_Edge : Long_Float; - Justification : Long_Float_0_1_Type; + Justification : Long_Float; The_Text : String) is begin plmtex(To_C(Side, True), Position_From_Edge, Position_Along_Edge, Justification, To_C(The_Text, True)); @@ -2614,7 +2614,7 @@ x_Min, x_Max : Long_Float; x_Jump : Long_Float; y_Min, y_Max : Long_Float; - x_Legend_Position, y_Legend_Position : Long_Float_0_1_Type; + x_Legend_Position, y_Legend_Position : Long_Float; Autoscale_Y : Boolean; Accumulate : Boolean; --Accumulate or slide Box_Color, Legend_Color : Plot_Color_Type; @@ -2626,8 +2626,8 @@ PL_Autoscale_Y, PL_Accumulate : PLBOOL; PL_Pen_Labels : Stripchart_String_Array; - x_LP : Long_Float_0_1_Type renames x_Legend_Position; - y_LP : Long_Float_0_1_Type renames y_Legend_Position; + x_LP : Long_Float renames x_Legend_Position; + y_LP : Long_Float renames y_Legend_Position; begin if Autoscale_Y then Modified: trunk/bindings/ada/plplot.ads =================================================================== --- trunk/bindings/ada/plplot.ads 2007-09-26 18:51:38 UTC (rev 7889) +++ trunk/bindings/ada/plplot.ads 2007-09-26 18:53:39 UTC (rev 7890) @@ -2,7 +2,7 @@ -- Thick Ada binding to PLplot --- Copyright (C) 2006-2007 Jerry Bauck +-- Copyright (C) 2006-2007 Jerry Bauck -- This file is part of PLplot. @@ -1045,7 +1045,7 @@ (Side : String; Position_From_Edge : Long_Float; Position_Along_Edge : Long_Float; - Justification : Long_Float_0_1_Type; + Justification : Long_Float; The_Text : String); @@ -1450,7 +1450,7 @@ x_Min, x_Max : Long_Float; x_Jump : Long_Float; y_Min, y_Max : Long_Float; - x_Legend_Position, y_Legend_Position : Long_Float_0_1_Type; + x_Legend_Position, y_Legend_Position : Long_Float; Autoscale_Y : Boolean; Accumulate : Boolean; --Accumulate or slide Box_Color, Legend_Color : Plot_Color_Type; Modified: trunk/bindings/ada/plplot_traditional.adb =================================================================== --- trunk/bindings/ada/plplot_traditional.adb 2007-09-26 18:51:38 UTC (rev 7889) +++ trunk/bindings/ada/plplot_traditional.adb 2007-09-26 18:53:39 UTC (rev 7890) @@ -2,7 +2,7 @@ -- Ada binding to PLplot using the traditional PLplot subprogram names --- Copyright (C) 2006-2007 Jerry Bauck +-- Copyright (C) 2006-2007 Jerry Bauck -- This file is part of PLplot. @@ -1841,7 +1841,7 @@ (Side : String; Position_From_Edge : Long_Float; Position_Along_Edge : Long_Float; - Justification : Long_Float_0_1_Type; + Justification : Long_Float; The_Text : String) is begin PLplot_Thin.plmtex(To_C(Side, True), Position_From_Edge, Position_Along_Edge, Justification, To_C(The_Text, True)); @@ -2494,7 +2494,7 @@ x_Min, x_Max : Long_Float; x_Jump : Long_Float; y_Min, y_Max : Long_Float; - x_Legend_Position, y_Legend_Position : Long_Float_0_1_Type; + x_Legend_Position, y_Legend_Position : Long_Float; Autoscale_Y : Boolean; Accumulate : Boolean; --Accumulate or slide Box_Color, Legend_Color : Plot_Color_Type; @@ -2506,8 +2506,8 @@ PL_Autoscale_Y, PL_Accumulate : PLBOOL; PL_Pen_Labels : Stripchart_String_Array; - x_LP : Long_Float_0_1_Type renames x_Legend_Position; - y_LP : Long_Float_0_1_Type renames y_Legend_Position; + x_LP : Long_Float renames x_Legend_Position; + y_LP : Long_Float renames y_Legend_Position; begin if Autoscale_Y then Modified: trunk/bindings/ada/plplot_traditional.ads =================================================================== --- trunk/bindings/ada/plplot_traditional.ads 2007-09-26 18:51:38 UTC (rev 7889) +++ trunk/bindings/ada/plplot_traditional.ads 2007-09-26 18:53:39 UTC (rev 7890) @@ -2,7 +2,7 @@ -- Ada binding to PLplot using the traditional PLplot subprogram names --- Copyright (C) 2006-2007 Jerry Bauck +-- Copyright (C) 2006-2007 Jerry Bauck -- This file is part of PLplot. @@ -970,7 +970,7 @@ (Side : String; Position_From_Edge : Long_Float; Position_Along_Edge : Long_Float; - Justification : Long_Float_0_1_Type; + Justification : Long_Float; The_Text : String); @@ -1324,7 +1324,7 @@ x_Min, x_Max : Long_Float; x_Jump : Long_Float; y_Min, y_Max : Long_Float; - x_Legend_Position, y_Legend_Position : Long_Float_0_1_Type; + x_Legend_Position, y_Legend_Position : Long_Float; Autoscale_Y : Boolean; Accumulate : Boolean; --Accumulate or slide Box_Color, Legend_Color : Plot_Color_Type; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2007-10-14 15:42:26
|
Revision: 7929 http://plplot.svn.sourceforge.net/plplot/?rev=7929&view=rev Author: airwin Date: 2007-10-14 08:42:29 -0700 (Sun, 14 Oct 2007) Log Message: ----------- Rename configured Ada source files using a .cmake suffix to distinguish them from the configured results (without the suffix) in the build tree. A .cmake suffix is a standard identifier for any file configured by CMake and also avoids a potential name clash for the case where the build tree is the same as the source tree. Modified Paths: -------------- trunk/bindings/ada/CMakeLists.txt Added Paths: ----------- trunk/bindings/ada/plplot.adb.cmake trunk/bindings/ada/plplot.ads.cmake trunk/bindings/ada/plplot_auxiliary.adb.cmake trunk/bindings/ada/plplot_auxiliary.ads.cmake trunk/bindings/ada/plplot_thin.adb.cmake trunk/bindings/ada/plplot_thin.ads.cmake trunk/bindings/ada/plplot_traditional.adb.cmake trunk/bindings/ada/plplot_traditional.ads.cmake Removed Paths: ------------- trunk/bindings/ada/plplot.adb trunk/bindings/ada/plplot.ads trunk/bindings/ada/plplot_auxiliary.adb trunk/bindings/ada/plplot_auxiliary.ads trunk/bindings/ada/plplot_thin.adb trunk/bindings/ada/plplot_thin.ads trunk/bindings/ada/plplot_traditional.adb trunk/bindings/ada/plplot_traditional.ads Modified: trunk/bindings/ada/CMakeLists.txt =================================================================== --- trunk/bindings/ada/CMakeLists.txt 2007-10-14 15:31:09 UTC (rev 7928) +++ trunk/bindings/ada/CMakeLists.txt 2007-10-14 15:42:29 UTC (rev 7929) @@ -34,7 +34,7 @@ set(plplotada${LIB_TAG}_LIB_SRCS) foreach(SOURCE_FILE ${SOURCE_LIST}) configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE} + ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE}.cmake ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_FILE} ) set(plplotada${LIB_TAG}_LIB_SRCS Deleted: trunk/bindings/ada/plplot.adb =================================================================== --- trunk/bindings/ada/plplot.adb 2007-10-14 15:31:09 UTC (rev 7928) +++ trunk/bindings/ada/plplot.adb 2007-10-14 15:42:29 UTC (rev 7929) @@ -1,2990 +0,0 @@ --- $Id$ - --- Thick Ada binding to PLplot - --- Copyright (C) 2006-2007 Jerry Bauck - --- This file is part of PLplot. - --- PLplot is free software; you can redistribute it and/or modify --- it under the terms of the GNU General Library Public License as published --- by the Free Software Foundation; either version 2 of the License, or --- (at your option) any later version. - --- PLplot 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 Library General Public License for more details. - --- You should have received a copy of the GNU Library General Public License --- along with PLplot; if not, write to the Free Software --- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -with - PLplot_Thin, - PLplot_Auxiliary, - Ada.Text_IO, - Ada.Numerics.Long_Elementary_Functions, - Ada.Strings.Unbounded, - Ada.Unchecked_Conversion, - Ada.Strings.Maps, - Ada.Command_Line, - System, - System.Address_To_Access_Conversions, - Interfaces.C.Pointers, - Interfaces.C; -use - PLplot_Thin, - PLplot_Auxiliary, - Ada.Text_IO, - Ada.Numerics.Long_Elementary_Functions, - Ada.Strings.Unbounded, - Interfaces.C; - --- COMMENT THIS LINE IF YOUR COMPILER DOES NOT INCLUDE THESE --- DEFINITIONS, FOR EXAMPLE, IF IT IS NOT ADA 2005 WITH ANNEX G.3 COMPLIANCE. ---with Ada.Numerics.Long_Real_Arrays; use Ada.Numerics.Long_Real_Arrays; -@Ada_Is_2007_With_and_Use_Numerics@ - -package body PLplot is - --------------------------------------------------------------------------------- --- High-Level subroutines for thick binding -- --------------------------------------------------------------------------------- - - -- When asked to draw white lines on black background, do it. - -- This is the default. - procedure Draw_White_On_Black is - begin - Set_One_Color_Map_0(Black, 0, 0 , 0); - Set_One_Color_Map_0(White, 255, 255, 255); - end Draw_White_On_Black; - - - -- When asked to draw black lines on white background, reverse black and white. - -- This might look better on anti-aliased displays. - -- fix this Darken some colors which have low contrast on white background, e.g. Yellow. - -- fix this Make a version that draws on white and converts _all_ colors to black for publications. - procedure Draw_Black_On_White is - begin - Set_One_Color_Map_0(Black, 255, 255, 255); - Set_One_Color_Map_0(White, 0, 0, 0); - end Draw_Black_On_White; - - - -- Set default pen width. Docs don't say, so I'll make it 1. - -- I could make this depend on the type of outut device used. - Default_Pen_Width : constant Integer := 1; - procedure Set_Default_Pen_Width is - begin - Set_Pen_Width(Default_Pen_Width); - end Set_Default_Pen_Width; - - - -- Plotter for up to five x-y pairs and settable axis style, plot - -- line colors, widths, and styles, justification, zoom, and labels. - -- Can be used directly or as part of a "simple" plotter - -- such as those that follow or which are made by the user. - procedure Multiplot_Pairs - (x1 : Real_Vector := Dont_Plot_This; - y1 : Real_Vector := Dont_Plot_This; - x2 : Real_Vector := Dont_Plot_This; - y2 : Real_Vector := Dont_Plot_This; - x3 : Real_Vector := Dont_Plot_This; - y3 : Real_Vector := Dont_Plot_This; - x4 : Real_Vector := Dont_Plot_This; - y4 : Real_Vector := Dont_Plot_This; - x5 : Real_Vector := Dont_Plot_This; - y5 : Real_Vector := Dont_Plot_This; - X_Labels : Label_String_Array_Type := Default_Label_String_Array; - Y_Labels : Label_String_Array_Type := Default_Label_String_Array; - Title_Labels : Label_String_Array_Type := Default_Label_String_Array; - Axis_Style : Axis_Style_Type := Linear_Box_Plus; - Colors : Color_Array_Type := Default_Color_Array; - Line_Widths : Line_Width_Array_Type := Default_Line_Width_Array; - Line_Styles : Line_Style_Array_Type := Default_Line_Style_Array; - Justification : Justification_Type := Not_Justified; - x_Min_Zoom : Long_Float := Long_Float'small; - x_Max_Zoom : Long_Float := Long_Float'large; - y_Min_Zoom : Long_Float := Long_Float'small; - y_Max_Zoom : Long_Float := Long_Float'large) is - - x_Min, y_Min : Long_Float := Long_Float'large; - x_Max, y_Max : Long_Float := Long_Float'small; - - begin - -- Set or find x_Min. - if x_Min_Zoom /= Long_Float'small then -- zoom - x_Min := x_Min_Zoom; - else -- Auto-scale x_Min. - if x1'length /= 1 then - x_Min := Long_Float'min(x_Min, Vector_Min(x1)); - end if; - if x2'length /= 1 then - x_Min := Long_Float'min(x_Min, Vector_Min(x2)); - end if; - if x3'length /= 1 then - x_Min := Long_Float'min(x_Min, Vector_Min(x3)); - end if; - if x4'length /= 1 then - x_Min := Long_Float'min(x_Min, Vector_Min(x4)); - end if; - if x5'length /= 1 then - x_Min := Long_Float'min(x_Min, Vector_Min(x5)); - end if; - end if; -- Set or find x_Min. - - -- Set or find x_Max. - if x_Max_Zoom /= Long_Float'large then -- zoom - x_Max := x_Max_Zoom; - else -- Auto-scale x_Max. - if x1'length /= 1 then - x_Max := Long_Float'max(x_Max, Vector_Max(x1)); - end if; - if x2'length /= 1 then - x_Max := Long_Float'max(x_Max, Vector_Max(x2)); - end if; - if x3'length /= 1 then - x_Max := Long_Float'max(x_Max, Vector_Max(x3)); - end if; - if x4'length /= 1 then - x_Max := Long_Float'max(x_Max, Vector_Max(x4)); - end if; - if x5'length /= 1 then - x_Max := Long_Float'max(x_Max, Vector_Max(x5)); - end if; - end if; -- Set or find x_Max. - - -- Set or find y_Min. - if y_Min_Zoom /= Long_Float'small then -- zoom - y_Min := y_Min_Zoom; - else -- Auto-scale y_Min. - if y1'length /= 1 then - y_Min := Long_Float'min(y_Min, Vector_Min(y1)); - end if; - if y2'length /= 1 then - y_Min := Long_Float'min(y_Min, Vector_Min(y2)); - end if; - if y3'length /= 1 then - y_Min := Long_Float'min(y_Min, Vector_Min(y3)); - end if; - if y4'length /= 1 then - y_Min := Long_Float'min(y_Min, Vector_Min(y4)); - end if; - if y5'length /= 1 then - y_Min := Long_Float'min(y_Min, Vector_Min(y5)); - end if; - end if; -- Set or find y_Min. - - -- Set or find y_Max. - if y_Max_Zoom /= Long_Float'large then -- zoom - y_Max := y_Max_Zoom; - else -- Auto-scale y_Max. - if y1'length /= 1 then - y_Max := Long_Float'max(y_Max, Vector_Max(y1)); - end if; - if y2'length /= 1 then - y_Max := Long_Float'max(y_Max, Vector_Max(y2)); - end if; - if y3'length /= 1 then - y_Max := Long_Float'max(y_Max, Vector_Max(y3)); - end if; - if y4'length /= 1 then - y_Max := Long_Float'max(y_Max, Vector_Max(y4)); - end if; - if y5'length /= 1 then - y_Max := Long_Float'max(y_Max, Vector_Max(y5)); - end if; - end if; -- Set or find x_Max. - - - -- Set environment and its color. - Set_Pen_Color(White); --- Set_Environment_Clear_Subpage(x_Min, x_Max, y_Min, y_Max, Justification, Axis_Style); - Set_Environment(x_Min, x_Max, y_Min, y_Max, Justification, Axis_Style); - - if x1'length /= 1 and y1'length /= 1 then - Write_Labels(To_String(X_Labels(1)), To_String(Y_Labels(1)), To_String(Title_Labels(1))); - Set_Pen_Color(Colors(1)); - Select_Line_Style(Line_Styles(1)); - Draw_Curve(x1, y1); - end if; - - if x2'length /= 1 and y2'length /= 1 then - Write_Labels(To_String(X_Labels(2)), To_String(Y_Labels(2)), To_String(Title_Labels(2))); - Set_Pen_Color(Colors(2)); - Select_Line_Style(Line_Styles(2)); - Draw_Curve(x2, y2); - end if; - - if x3'length /= 1 and y3'length /= 1 then - Write_Labels(To_String(X_Labels(3)), To_String(Y_Labels(3)), To_String(Title_Labels(3))); - Set_Pen_Color(Colors(3)); - Select_Line_Style(Line_Styles(3)); - Draw_Curve(x3, y3); - end if; - - if x4'length /= 1 and y4'length /= 1 then - Write_Labels(To_String(X_Labels(4)), To_String(Y_Labels(4)), To_String(Title_Labels(4))); - Set_Pen_Color(Colors(4)); - Select_Line_Style(Line_Styles(4)); - Draw_Curve(x4, y4); - end if; - - if x5'length /= 1 and y5'length /= 1 then - Write_Labels(To_String(X_Labels(5)), To_String(Y_Labels(5)), To_String(Title_Labels(5))); - Set_Pen_Color(Colors(5)); - Select_Line_Style(Line_Styles(5)); - Draw_Curve(x5, y5); - end if; - - Set_Pen_Color(White); - Set_Default_Pen_Width; - Select_Line_Style(1); --solid - end Multiplot_Pairs; - - ---------- Simple plotters requiring minimal arguments ----- - - - -- Simple plotter for single x array and multiple y arrays - procedure Simple_Plot - (x : Real_Vector; - y1 : Real_Vector := Dont_Plot_This; - y2 : Real_Vector := Dont_Plot_This; - y3 : Real_Vector := Dont_Plot_This; - y4 : Real_Vector := Dont_Plot_This; - y5 : Real_Vector := Dont_Plot_This; - X_Label : String := To_String(Default_Label_String); - Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String)) is - - X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - - begin - X_Label_String_Array(1) := TUB(X_Label); -- First slot only; others not used. - Y_Label_String_Array(1) := TUB(Y_Label); -- First slot only; others not used. - Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. - - Multiplot_Pairs(x, y1, x, y2, x, y3, x, y4, x, y5, - X_Labels => X_Label_String_Array, - Y_Labels => Y_Label_String_Array, - Title_Labels => Title_Label_String_Array, - Axis_Style => Linear_Major_Grid); - end Simple_Plot; - - - -- Simple log x plotter for single x array and multiple y arrays - -- fix this: Automatically skip zero-valued abscissa; place marker at the - -- left-hand side of the plot at the ordinate of the deleted point. - procedure Simple_Plot_Log_X - (x : Real_Vector; - y1 : Real_Vector := Dont_Plot_This; - y2 : Real_Vector := Dont_Plot_This; - y3 : Real_Vector := Dont_Plot_This; - y4 : Real_Vector := Dont_Plot_This; - y5 : Real_Vector := Dont_Plot_This; - X_Label : String := To_String(Default_Label_String); - Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String); - Log_Base : Long_Float := 10.0) is -- Should this default to e? - - X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - - x_Log : Real_Vector(x'range); - - begin - X_Label_String_Array(1) := TUB(X_Label); -- First slot only; others not used. - Y_Label_String_Array(1) := TUB(Y_Label); -- First slot only; others not used. - Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. - - for i in x_Log'range loop - x_Log(i) := Log(x(i), Log_Base); - end loop; - Multiplot_Pairs(x_Log, y1, x_Log, y2, x_Log, y3, x_Log, y4, x_Log, y5, - X_Labels => X_Label_String_Array, - Y_Labels => Y_Label_String_Array, - Title_Labels => Title_Label_String_Array, - Axis_Style => Log_X_Minor_Grid); - end Simple_Plot_Log_X; - - - -- Simple log y plotter for multiple x arrays and single y array - -- fix this: Automatically skip zero-valued ordinate; place marker at the - -- bottom of the plot at the abscissa of the deleted point. - procedure Simple_Plot_Log_Y - (x1 : Real_Vector := Dont_Plot_This; - y : Real_Vector := Dont_Plot_This; -- Beware of argument order. - x2 : Real_Vector := Dont_Plot_This; - x3 : Real_Vector := Dont_Plot_This; - x4 : Real_Vector := Dont_Plot_This; - x5 : Real_Vector := Dont_Plot_This; - X_Label : String := To_String(Default_Label_String); - Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String); - Log_Base : Long_Float := 10.0) is -- Should this default to e? - - X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - - y_Log : Real_Vector(y'range); - - begin - X_Label_String_Array(1) := TUB(X_Label); -- First slot only; others not used. - Y_Label_String_Array(1) := TUB(Y_Label); -- First slot only; others not used. - Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. - - for i in y_Log'range loop - y_Log(i) := Log(y(i), Log_Base); - end loop; - Multiplot_Pairs(x1, y_Log, x2, y_Log, x3, y_Log, x4, y_Log, x5, y_Log, - X_Labels => X_Label_String_Array, - Y_Labels => Y_Label_String_Array, - Title_Labels => Title_Label_String_Array, - Axis_Style => Log_Y_Minor_Grid); - end Simple_Plot_Log_Y; - - - -- Simple log x - log y plotter - procedure Simple_Plot_Log_XY - (x, y : Real_Vector; - X_Label : String := To_String(Default_Label_String); - Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String); - x_Log_Base, y_Log_Base : Long_Float := 10.0) is -- Should this default to e? - - X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - - x_Log : Real_Vector(x'range); - y_Log : Real_Vector(y'range); - begin - X_Label_String_Array(1) := TUB(X_Label); -- First slot only; others not used. - Y_Label_String_Array(1) := TUB(Y_Label); -- First slot only; others not used. - Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. - - for i in x_Log'range loop - x_Log(i) := Log(x(i), x_Log_Base); - y_Log(i) := Log(y(i), y_Log_Base); - end loop; - Multiplot_Pairs(x_Log, y_Log, - X_Labels => X_Label_String_Array, - Y_Labels => Y_Label_String_Array, - Title_Labels => Title_Label_String_Array, - Axis_Style => Log_XY_Minor_Grid); - end Simple_Plot_Log_XY; - - - -- Simple plotter for multiple x-y arrays specified pairwise. - procedure Simple_Plot_Pairs - (x1 : Real_Vector := Dont_Plot_This; - y1 : Real_Vector := Dont_Plot_This; - x2 : Real_Vector := Dont_Plot_This; - y2 : Real_Vector := Dont_Plot_This; - x3 : Real_Vector := Dont_Plot_This; - y3 : Real_Vector := Dont_Plot_This; - x4 : Real_Vector := Dont_Plot_This; - y4 : Real_Vector := Dont_Plot_This; - x5 : Real_Vector := Dont_Plot_This; - y5 : Real_Vector := Dont_Plot_This; - X_Label : String := To_String(Default_Label_String); - Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String)) is - - X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - begin - X_Label_String_Array(1) := TUB(X_Label); -- First slot only; others not used. - Y_Label_String_Array(1) := TUB(Y_Label); -- First slot only; others not used. - Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. - - Multiplot_Pairs(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, - X_Labels => X_Label_String_Array, - Y_Labels => Y_Label_String_Array, - Title_Labels => Title_Label_String_Array, - Axis_Style => Linear_Major_Grid); - end Simple_Plot_Pairs; - - ---------- Plotter requiring somewhat more arguments ------ - - -- Single plotter with flexible attributes - -- Similar to Multiplot_Pairs except single trace and no attribute arrays. - procedure Single_Plot - (x, y : Real_Vector; - X_Label : String := To_String(Default_Label_String); - Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String); - Axis_Style : Axis_Style_Type := Linear_Major_Grid; - Color : Plot_Color_Type := Red; - Line_Width : Integer := 1; - Line_Style : Line_Style_Type := 1; - Justification : Justification_Type := Not_Justified; - x_Min_Zoom : Long_Float := Long_Float'small; - x_Max_Zoom : Long_Float := Long_Float'large; - y_Min_Zoom : Long_Float := Long_Float'small; - y_Max_Zoom : Long_Float := Long_Float'large) is - - X_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - Y_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - Title_Label_String_Array : Label_String_Array_Type := Default_Label_String_Array; - Color_Array : Color_Array_Type := Default_Color_Array; - Line_Width_Array : Line_Width_Array_Type := Default_Line_Width_Array; - Line_Style_Array : Line_Style_Array_Type := Default_Line_Style_Array; - - begin - X_Label_String_Array(1) := TUB(X_Label); -- First slot only; others not used. - Y_Label_String_Array(1) := TUB(Y_Label); -- First slot only; others not used. - Title_Label_String_Array(1) := TUB(Title_Label); -- First slot only; others not used. - Color_Array(1) := Color; - Line_Width_Array(1) := Line_Width; -- First slot only; others not used. - Line_Style_Array(1) := Line_Style; -- First slot only; others not used. - - -- Process arrays if log plot is indicated. - -- The declare blocks save memory and time for non-log plots. - - -- Log x. - if Axis_Style in Log_X_Box_Plus..Log_X_Minor_Grid then - declare - x_Log : Real_Vector(x'range); - begin - for i in x_Log'range loop - x_Log(i) := Log(x(i), 10.0); - end loop; - - Multiplot_Pairs( - x_Log, y, - X_Labels => X_Label_String_Array, - Y_Labels => Y_Label_String_Array, - Title_Labels => Title_Label_String_Array, - Axis_Style => Axis_Style, - Colors => Color_Array, - Line_Widths => Line_Width_Array, - Line_Styles => Line_Style_Array, - Justification => Justification, - x_Min_Zoom => x_Min_Zoom, - x_Max_Zoom => x_Max_Zoom, - y_Min_Zoom => y_Min_Zoom, - y_Max_Zoom => y_Max_Zoom); - end; -- declare - end if; -- log x - - -- Log y - if Axis_Style in Log_Y_Box_Plus..Log_Y_Minor_Grid then - declare - y_Log : Real_Vector(y'range); - begin - for i in y_Log'range loop - y_Log(i) := Log(y(i), 10.0); - end loop; - Multiplot_Pairs( - x, y_Log, - X_Labels => X_Label_String_Array, - Y_Labels => Y_Label_String_Array, - Title_Labels => Title_Label_String_Array, - Axis_Style => Axis_Style, - Colors => Color_Array, - Line_Widths => Line_Width_Array, - Line_Styles => Line_Style_Array, - Justification => Justification, - x_Min_Zoom => x_Min_Zoom, - x_Max_Zoom => x_Max_Zoom, - y_Min_Zoom => y_Min_Zoom, - y_Max_Zoom => y_Max_Zoom); - end; -- declare - end if; -- log y - - -- Log x and log y - if Axis_Style in Log_XY_Box_Plus..Log_XY_Minor_Grid then - declare - x_Log : Real_Vector(x'range); - y_Log : Real_Vector(y'range); - begin - for i in x_Log'range loop - x_Log(i) := Log(x(i), 10.0); - y_Log(i) := Log(y(i), 10.0); - end loop; - Multiplot_Pairs( - x_Log, y_Log, - X_Labels => X_Label_String_Array, - Y_Labels => Y_Label_String_Array, - Title_Labels => Title_Label_String_Array, - Axis_Style => Axis_Style, - Colors => Color_Array, - Line_Widths => Line_Width_Array, - Line_Styles => Line_Style_Array, - Justification => Justification, - x_Min_Zoom => x_Min_Zoom, - x_Max_Zoom => x_Max_Zoom, - y_Min_Zoom => y_Min_Zoom, - y_Max_Zoom => y_Max_Zoom); - end; -- declare - end if; -- log x and log y - - -- Linear plot is indicated. - if Axis_Style in No_Box..Linear_Minor_Grid then - Multiplot_Pairs( - x, y, - X_Labels => X_Label_String_Array, - Y_Labels => Y_Label_String_Array, - Title_Labels => Title_Label_String_Array, - Axis_Style => Axis_Style, - Colors => Color_Array, - Line_Widths => Line_Width_Array, - Line_Styles => Line_Style_Array, - Justification => Justification, - x_Min_Zoom => x_Min_Zoom, - x_Max_Zoom => x_Max_Zoom, - y_Min_Zoom => y_Min_Zoom, - y_Max_Zoom => y_Max_Zoom); - end if; -- Linear plot - end Single_Plot; - - ---------- Simple Contour Plotter ------ - - -- Place-holder for the transformation data which is not used here. - Transformation_Data : aliased Transformation_Data_Type - (x_Length_Minus_1 => 2, y_Length_Minus_1 => 2, z_Length_Minus_1 => 2); - - procedure Simple_Contour - (z : Real_Matrix; - Number_Levels : Integer := 10; - X_Label : String := To_String(Default_Label_String); - Y_Label : String := To_String(Default_Label_String); - Title_Label : String := To_String(Default_Label_String)) is - - Contour_Levels : Real_Vector (0 .. Number_Levels); - Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type; - - begin - -- Fill up the dummy transformation data with something so we don't get warnings. - for i in Transformation_Data.xg'range loop -- use shorthand for .all on pointer - Transformation_Data.xg(i) := 0.0; - end loop; - for i in Transformation_Data.yg'range loop - Transformation_Data.yg(i) := 0.0; - end loop; - for i in Transformation_Data.zg'range loop - Transformation_Data.zg(i) := 0.0; - end loop; - - -- Point to the do-nothing transformation procedure. - Transformation_Procedure_Pointer := PLplot_Thin.pltr0'access; - - -- Fill the contour vector with some levels. - Calculate_Contour_Levels(Contour_Levels, Matrix_Min(z), Matrix_Max(z)); - - Advance_To_Subpage(Next_Subpage); - Set_Viewport_Normalized(0.1, 0.9, 0.1, 0.9); - Set_Viewport_World(1.0, 35.0, 1.0, 46.0); -- fix - Set_Pen_Color(White); - Box_Around_Viewport("bcnst", 0.0, 0, "bcnstv", 0.0, 0); - Set_Pen_Color(White); - Write_Labels(X_Label, Y_Label, Title_Label); - Set_Pen_Color(White); - Set_Contour_Label_Parameters(0.008, 0.6, 0.1, True); - Contour_Plot(z, z'First(1), z'Last(1), z'First(2), z'Last(2), - Contour_Levels, Transformation_Procedure_Pointer, Transformation_Data); - end Simple_Contour; - - ---------- Simple 3D Mesh Plotter ------ - - procedure Simple_Mesh_3D - (x, y : Real_Vector; -- data definition points - z : Real_Matrix; -- z(x, y) = z(x(i), y(j)) - x_Min : Long_Float := 0.0; -- user coordinate limits - x_Max : Long_Float := 0.0; - y_Min : Long_Float := 0.0; - y_Max : Long_Float := 0.0; - Altitude : Long_Float := 30.0; -- viewing elevation angle in degrees - Azimuth : Long_Float := 30.0; -- viewing azimuth in degrees - X_Label : String := "x"; - Y_Label : String := "y"; - Z_Label : String := "z") is - - x_Min_Local, x_Max_Local, y_Min_Local, y_Max_Local : Long_Float; - - begin - -- Set min and max for x and y if they are not the defaults. - if x_Min = 0.0 and x_Max = 0.0 then -- override - x_Min_Local := Vector_Min(x); - x_Max_Local := Vector_Max(x); - else - x_Min_Local := x_Min; - x_Max_Local := x_Max; - end if; - - if y_Min = 0.0 and y_Max = 0.0 then -- override - y_Min_Local := Vector_Min(y); - y_Max_Local := Vector_Max(y); - else - y_Min_Local := y_Min; - y_Max_Local := y_Max; - end if; - - Quick_Set_Color_Map_1(Blue_Green_Red); -- no way to restore after doing this - Advance_To_Subpage(Next_Subpage); - Set_Pen_Color(White); - Set_Viewport_Normalized(0.0, 1.0, 0.0, 1.0); - Set_Viewport_World(-0.9, 0.9, -0.8, 1.5); - Set_Up_3D(1.0, 1.0, 1.0, x_Min_Local, x_Max_Local, y_Min_Local, y_Max_Local, - Matrix_Min(z), Matrix_Max(z), Altitude, Azimuth); -- plw3d - Box_Around_Viewport_3D("bnstu", X_Label, 0.0, 0, - "bnstu", Y_Label, 0.0, 0, - "bcdmnstuv", Z_Label, 0.0, 0); -- plbox3 - Mesh_3D(x, y, z, Lines_Parallel_To_X_And_Y + Magnitude_Color); -- plmesh - end Simple_Mesh_3D; - - ---------- Simple 3D Surface Plotter ------ - - procedure Simple_Surface_3D - (x, y : Real_Vector; -- data definition points - z : Real_Matrix; -- z(x, y) = z(x(i), y(j)) - x_Min : Long_Float := 0.0; -- user coordinate limits - x_Max : Long_Float := 0.0; - y_Min : Long_Float := 0.0; - y_Max : Long_Float := 0.0; - Altitude : Long_Float := 30.0; -- viewing elevation angle in degrees - Azimuth : Long_Float := 30.0; -- viewing azimuth in degrees - X_Label : String := "x"; - Y_Label : String := "y"; - Z_Label : String := "z") is - - x_Min_Local, x_Max_Local, y_Min_Local, y_Max_Local : Long_Float; - Contour_Levels_Dummy : Real_Vector(0..1) := (others => 0.0); - - begin - -- Set min and max for x and y if they are not the defaults. - if x_Min = 0.0 and x_Max = 0.0 then -- override - x_Min_Local := Vector_Min(x); - x_Max_Local := Vector_Max(x); - else - x_Min_Local := x_Min; - x_Max_Local := x_Max; - end if; - - if y_Min = 0.0 and y_Max = 0.0 then -- override - y_Min_Local := Vector_Min(y); - y_Max_Local := Vector_Max(y); - else - y_Min_Local := y_Min; - y_Max_Local := y_Max; - end if; - - Quick_Set_Color_Map_1(Blue_Green_Red); -- no way to restore after doing this - Advance_To_Subpage(Next_Subpage); - Set_Pen_Color(White); - Set_Viewport_Normalized(0.0, 1.0, 0.0, 1.0); - Set_Viewport_World(-0.9, 0.9, -0.8, 1.5); - Set_Up_3D(1.0, 1.0, 1.0, x_Min_Local, x_Max_Local, y_Min_Local, y_Max_Local, - Matrix_Min(z), Matrix_Max(z), Altitude, Azimuth); -- plw3d - Box_Around_Viewport_3D("bnstu", X_Label, 0.0, 0, - "bnstu", Y_Label, 0.0, 0, - "bcdmnstuv", Z_Label, 0.0, 0); -- plbox3 - Mesh_3D(x, y, z, Lines_Parallel_To_X_And_Y + Magnitude_Color); -- plmesh - Shaded_Surface_3D(x, y, z, Magnitude_Color, Contour_Levels_Dummy); - end Simple_Surface_3D; - - - ---------- Simple color table manipulatons ----- - - -- Things for manipulating color map 0 -- - - -- Make a snapshot of color map 0 for possible later full or partial restoration. - -- This is automatically called at package initialization with results stored - -- in Default_Red_Components, Default_Green_Components, Default_Blue_Components. - procedure Make_Snapshot_Of_Color_Map_0 - (Reds, Greens, Blues : out Integer_Array_1D) is - begin - for i in Reds'range loop - Get_Color_RGB(i, Reds(i), Greens(i), Blues(i)); - end loop; - end Make_Snapshot_Of_Color_Map_0; - - - -- Restore an arbitray snapshot of color map 0. - procedure Restore_Snapshot_Of_Color_Map_0 - (Reds, Greens, Blues : Integer_Array_1D) is - begin - Set_Color_Map_0(Reds, Greens, Blues); - end Restore_Snapshot_Of_Color_Map_0; - - - -- Restore the default colors of color map 0 taken as a snapshot at initialization. - procedure Restore_Default_Snapshot_Of_Color_Map_0 is - begin - Set_Number_Of_Colors_Map_0(Number_Of_Default_Colors); - Set_Color_Map_0(Default_Red_Components, Default_Green_Components, Default_Blue_Components); - end Restore_Default_Snapshot_Of_Color_Map_0; - - - -- Functions which correspond to the default colors of color map 0. Calling - -- one of these (1) resets the corresponding slot in color map 0 to its - -- default value, and (2) returns the correct integer value for the default - -- color specified. Thus, using Set_Pen_Color(Reset_Red) instead of - -- Set_Pen_Color(Red) guarantees that the color will be set to Red even if - -- there have been prior manipulations of color 1. - - function Reset_Black return Integer is - begin - Set_One_Color_Map_0(0, Default_Red_Components(0), Default_Green_Components(0), Default_Blue_Components(0)); - return 0; - end Reset_Black; - - function Reset_Red return Integer is - begin - Set_One_Color_Map_0(1, Default_Red_Components(1), Default_Green_Components(1), Default_Blue_Components(1)); - return 1; - end Reset_Red; - - function Reset_Yellow return Integer is - begin - Set_One_Color_Map_0(2, Default_Red_Components(2), Default_Green_Components(2), Default_Blue_Components(2)); - return 2; - end Reset_Yellow; - - function Reset_Green return Integer is - begin - Set_One_Color_Map_0(3, Default_Red_Components(3), Default_Green_Components(3), Default_Blue_Components(3)); - return 3; - end Reset_Green; - - function Reset_Aquamarine return Integer is - begin - Set_One_Color_Map_0(4, Default_Red_Components(4), Default_Green_Components(4), Default_Blue_Components(4)); - return 4; - end Reset_Aquamarine; - - function Reset_Pink return Integer is - begin - Set_One_Color_Map_0(5, Default_Red_Components(5), Default_Green_Components(5), Default_Blue_Components(5)); - return 5; - end Reset_Pink; - - function Reset_Wheat return Integer is - begin - Set_One_Color_Map_0(6, Default_Red_Components(6), Default_Green_Components(6), Default_Blue_Components(6)); - return 6; - end Reset_Wheat; - - function Reset_Grey return Integer is - begin - Set_One_Color_Map_0(7, Default_Red_Components(7), Default_Green_Components(7), Default_Blue_Components(7)); - return 7; - end Reset_Grey; - - function Reset_Brown return Integer is - begin - Set_One_Color_Map_0(8, Default_Red_Components(8), Default_Green_Components(8), Default_Blue_Components(8)); - return 8; - end Reset_Brown; - - function Reset_Blue return Integer is - begin - Set_One_Color_Map_0(9, Default_Red_Components(9), Default_Green_Components(9), Default_Blue_Components(9)); - return 9; - end Reset_Blue; - - function Reset_BlueViolet return Integer is - begin - Set_One_Color_Map_0(10, Default_Red_Components(10), Default_Green_Components(10), Default_Blue_Components(10)); - return 10; - end Reset_BlueViolet; - - function Reset_Cyan return Integer is - begin - Set_One_Color_Map_0(11, Default_Red_Components(11), Default_Green_Components(11), Default_Blue_Components(11)); - return 11; - end Reset_Cyan; - - function Reset_Turquoise return Integer is - begin - Set_One_Color_Map_0(12, Default_Red_Components(12), Default_Green_Components(12), Default_Blue_Components(12)); - return 12; - end Reset_Turquoise; - - function Reset_Magenta return Integer is - begin - Set_One_Color_Map_0(13, Default_Red_Components(13), Default_Green_Components(13), Default_Blue_Components(13)); - return 13; - end Reset_Magenta; - - function Reset_Salmon return Integer is - begin - Set_One_Color_Map_0(14, Default_Red_Components(14), Default_Green_Components(14), Default_Blue_Components(14)); - return 14; - end Reset_Salmon; - - function Reset_White return Integer is - begin - Set_One_Color_Map_0(15, Default_Red_Components(15), Default_Green_Components(15), Default_Blue_Components(15)); - return 15; - end Reset_White; - - - -- Things for manipulating color map 1 -- - - -- Quick application of pre-fabricated color schemes to color map 1. - procedure Quick_Set_Color_Map_1(Color_Theme : Color_Themes_For_Map_1_Type) is - - Controls_3 : Real_Vector (0..2); -- 3 control points - Controls_4 : Real_Vector (0..3); -- 4 control points - Red_3, Green_3, Blue_3 : Real_Vector (0..2); -- define 3 - Red_4, Green_4, Blue_4 : Real_Vector (0..3); -- define 4 - Hue_3, Lightness_3, Saturation_3 : Real_Vector (0..2); -- define 3 - Hue_4, Lightness_4, Saturation_4 : Real_Vector (0..3); -- define 4 - Reverse_Hue_3 : Boolean_Array_1D (0..2); - Reverse_Hue_4 : Boolean_Array_1D (0..3); - begin - Set_Number_Of_Colors_In_Color_Map_1(256); - - Controls_3(0) := 0.0; - Controls_3(1) := 0.5; - Controls_3(2) := 1.0; - - Controls_4(0) := 0.0; - Controls_4(1) := 0.5; -- allow a "bend" at the mid-point - Controls_4(2) := 0.5; -- allow a "bend" at the mid-point - Controls_4(3) := 1.0; - - -- Initialize everything, even unused stuff. - Red_3(0) := 0.0; - Red_3(1) := 0.0; - Red_3(2) := 0.0; - Green_3(0) := 0.0; - Green_3(1) := 0.0; - Green_3(2) := 0.0; - Blue_3(0) := 0.0; - Blue_3(1) := 0.0; - Blue_3(2) := 0.0; - - Red_4(0) := 0.0; - Red_4(1) := 0.0; - Red_4(2) := 0.0; - Red_4(3) := 0.0; - Green_4(0) := 0.0; - Green_4(1) := 0.0; - Green_4(2) := 0.0; - Green_4(3) := 0.0; - Blue_4(0) := 0.0; - Blue_4(1) := 0.0; - Blue_4(2) := 0.0; - Blue_4(3) := 0.0; - - Hue_3(0) := 0.0; - Hue_3(1) := 0.0; - Hue_3(2) := 0.0; - Lightness_3(0) := 0.0; - Lightness_3(1) := 0.0; - Lightness_3(2) := 0.0; - Saturation_3(0) := 0.0; - Saturation_3(1) := 0.0; - Saturation_3(2) := 0.0; - - Hue_4(0) := 0.0; - Hue_4(1) := 0.0; - Hue_4(2) := 0.0; - Hue_4(3) := 0.0; - Lightness_4(0) := 0.0; - Lightness_4(1) := 0.0; - Lightness_4(2) := 0.0; - Lightness_4(3) := 0.0; - Saturation_4(0) := 0.0; - Saturation_4(1) := 0.0; - Saturation_4(2) := 0.0; - Saturation_4(3) := 0.0; - - case Color_Theme is - when Gray => - begin - Hue_3(0) := 0.0; - Hue_3(1) := 0.0; - Hue_3(2) := 0.0; - Lightness_3(0) := 0.0; - Lightness_3(1) := 0.5; - Lightness_3(2) := 1.0; - Saturation_3(0) := 0.0; - Saturation_3(1) := 0.0; - Saturation_3(2) := 0.0; - Reverse_Hue_3(0) := False; - Reverse_Hue_3(1) := False; - Reverse_Hue_3(2) := False; - Set_Color_Map_1_Piecewise(HLS, Controls_3, Hue_3, Lightness_3, Saturation_3, Reverse_Hue_3); - end; - when Blue_Green_Red => - begin - Blue_3(0) := 1.0; - Blue_3(1) := 0.0; - Blue_3(2) := 0.0; - Green_3(0) := 0.0; - Green_3(1) := 1.0; - Green_3(2) := 0.0; - Red_3(0) := 0.0; - Red_3(1) := 0.0; - Red_3(2) := 1.0; - Reverse_Hue_3(0) := False; - Reverse_Hue_3(1) := False; - Reverse_Hue_3(2) := False; - Set_Color_Map_1_Piecewise(RGB, Controls_3, Red_3, Green_3, Blue_3, Reverse_Hue_3); - end; - when Red_Green_Blue => - begin - Blue_3(0) := 0.0; - Blue_3(1) := 0.0; - Blue_3(2) := 1.0; - Green_3(0) := 0.0; - Green_3(1) := 1.0; - Green_3(2) := 0.0; - Red_3(0) := 1.0; - Red_3(1) := 0.0; - Red_3(2) := 0.0; - Reverse_Hue_3(0) := False; - Reverse_Hue_3(1) := False; - Reverse_Hue_3(2) := False; - Set_Color_Map_1_Piecewise(RGB, Controls_3, Red_3, Green_3, Blue_3, Reverse_Hue_3); - end; - when Red_Cyan_Blue => - begin - Hue_3(0) := 360.0; - Hue_3(1) := 300.0; - Hue_3(2) := 240.0; - Saturation_3(0) := 1.0; - Saturation_3(1) := 1.0; - Saturation_3(2) := 1.0; - Lightness_3(0) := 0.5; - Lightness_3(1) := 0.5; - Lightness_3(2) := 0.5; - Reverse_Hue_3(0) := False; - Reverse_Hue_3(1) := False; - Reverse_Hue_3(2) := False; - Set_Color_Map_1_Piecewise(HLS, Controls_3, Hue_3, Lightness_3, Saturation_3, Reverse_Hue_3); - end; - when Blue_Black_Red => - begin - Hue_4(0) := 240.0; -- Blue - Hue_4(1) := 240.0; -- Blue - Hue_4(2) := 0.0; -- Red - Hue_4(3) := 0.0; -- Red - Saturation_4(0) := 1.0; - Saturation_4(1) := 1.0; - Saturation_4(2) := 1.0; - Saturation_4(3) := 1.0; - Lightness_4(0) := 0.5; -- Apparently different from Brightness - Lightness_4(1) := 0.0; - Lightness_4(2) := 0.0; - Lightness_4(3) := 0.5; - Reverse_Hue_4(0) := False; - Reverse_Hue_4(1) := False; - Reverse_Hue_4(2) := False; - Reverse_Hue_4(3) := False; - Set_Color_Map_1_Piecewise(HLS, Controls_4, Hue_4, Lightness_4, Saturation_4, Reverse_Hue_4); - end; - when Red_Blue_Green => - begin - Hue_3(0) := 360.0; -- red - Hue_3(1) := 210.0; -- blue - Hue_3(2) := 120.0; -- green - Lightness_3(0) := 0.5; - Lightness_3(1) := 0.5; - Lightness_3(2) := 0.5; - Saturation_3(0) := 1.0; - Saturation_3(1) := 1.0; - Saturation_3(2) := 1.0; - Reverse_Hue_3(0) := False; - Reverse_Hue_3(1) := False; - Reverse_Hue_3(2) := False; - Set_Color_Map_1_Piecewise(HLS, Controls_3, Hue_3, Lightness_3, Saturation_3, Reverse_Hue_3); - end; - when Red_Yellow => - begin - Hue_3(0) := 0.0; -- red - Hue_3(1) := 30.0; -- orange - Hue_3(2) := 60.0; -- yellow - Lightness_3(0) := 0.5; - Lightness_3(1) := 0.5; - Lightness_3(2) := 0.5; - Saturation_3(0) := 1.0; - Saturation_3(1) := 1.0; - Saturation_3(2) := 1.0; - Reverse_Hue_3(0) := False; - Reverse_Hue_3(1) := False; - Reverse_Hue_3(2) := False; - Set_Color_Map_1_Piecewise(HLS, Controls_3, Hue_3, Lightness_3, Saturation_3, Reverse_Hue_3); - end; - end case; - end Quick_Set_Color_Map_1; - - --------------------------------------------------------------------------------- --- Auxiliary things -- --------------------------------------------------------------------------------- - - -- This is a mask function for Shade_Regions (aka plshades) et al that always - -- returns 1 so that all points are plotted. Can be used as a template - -- for other user-written mask functions. This behave the same as - -- when passing null for the second argument in Shade_Regions. - function Mask_Function_No_Mask(x, y : Long_Float) return Integer is - begin - return 1; - end Mask_Function_No_Mask; - - - -- Given an array to hold contour levels and function minimum and maximum, - -- fill it and return. Useful for contour and shade plots. - procedure Calculate_Contour_Levels - (Contour_Levels : in out Real_Vector; - z_Min, z_Max : Long_Float) is - - step : Long_Float; - ii : Integer; - begin - step := (z_Max - z_Min) / Long_Float(Contour_Levels'Last - Contour_Levels'First); - for i in Contour_Levels'range loop - ii := i - Contour_Levels'First; -- reference back to 0. - Contour_Levels(i) := z_Min + step * Long_Float(ii); - end loop; - end Calculate_Contour_Levels; - - --------------------------------------------------------------------------------- --- Re-define PLplot procedures using Ada style. -- --------------------------------------------------------------------------------- - --- These correspond to the section in plot.h called "Function Prototypes". - - -- set the format of the contour labels - -- pl_setcontlabelformat - procedure Set_Contour_Label_Format - (Limit_Exponent : Integer := 4; - Significant_Digits : Integer := 2) is - begin - pl_setcontlabelformat(Limit_Exponent, Significant_Digits); - end Set_Contour_Label_Format; - - - -- set offset and spacing of contour labels - -- pl_setcontlabelparam - procedure Set_Contour_Label_Parameters - (Label_Offset : Long_Float := 0.006; -- Units are ??? - Label_Font_Height : Long_Float := 0.3; -- Units are ??? - Label_Spacing : Long_Float := 0.1; -- Units are??? - Labels_Active : Boolean := False) is - - active : Integer; - - begin - if Labels_Active then - active := 1; - else - active := 0; - end if; - pl_setcontlabelparam(Label_Offset, Label_Font_Height, Label_Spacing, active); - end Set_Contour_Label_Parameters; - - - -- Advance to subpage "page", or to the next one if "page" = 0. - -- pladv - procedure Advance_To_Subpage(Page : Natural) is - begin - pladv(Page); - end Advance_To_Subpage; - - - -- fix this - -- simple arrow plotter. - -- plarrows - procedure Arrow_Plotter is - begin - Put_Line("Not implemented due to lack of documentation."); - end Arrow_Plotter; - - - -- fix this See comment for plcont. - -- Draw a 2D vector plot. - -- plvect - procedure Vector_Plot - (u, v : Real_Matrix; - Scale : Long_Float; - Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type; - Transformation_Data : Transformation_Data_Type) is - - Transformation_Data_Address : PLpointer; - begin - Transformation_Data_Address := Transformation_Data'Address; - plvect(Matrix_To_Pointers(u), Matrix_To_Pointers(v), u'Length(1), u'Length(2), Scale, Transformation_Procedure_Pointer, Transformation_Data_Address); - end Vector_Plot; - - - -- Set the style for the arrow used by plvect to plot vectors. - -- plsvect - procedure Set_Arrow_Style_For_Vector_Plots - (X_Vertices, Y_Vertices : Real_Vector; -- Should be range -0.5..0.5 - Fill_Arrow : Boolean) is - - fill : PLBOOL; - - begin - if Fill_Arrow then - fill := PLtrue; - else - fill := PLfalse; - end if; - plsvect(X_Vertices, Y_Vertices, X_Vertices'length, fill); - end Set_Arrow_Style_For_Vector_Plots; - - - -- This functions similarly to plbox() except that the origin of the axes - -- is placed at the user-specified point (x0, y0). - -- plaxes - procedure Box_Around_Viewport_With_Origin - (X_Origin, Y_Origin : Long_Float; - X_Option_String : String; - X_Major_Tick_Interval : Long_Float; - X_Number_Of_Subintervals : Natural; - Y_Option_String : String; - Y_Major_Tick_Interval : Long_Float; - Y_Number_Of_Subintervals : Natural) is - begin - plaxes - (X_Origin, Y_Origin, - To_C(X_Option_String, True), X_Major_Tick_Interval, X_Number_Of_Subintervals, - To_C(Y_Option_String, True), Y_Major_Tick_Interval, Y_Number_Of_Subintervals); - end Box_Around_Viewport_With_Origin; - - - -- Plot a histogram using x to store data values and y to store frequencies - -- plbin - procedure Histogram_Binned - (Bin_Values : Real_Vector; -- "x" - Bin_Counts : Real_Vector; -- "y" - Options : Integer) is -- Options are not defined in plplot.h. - begin - plbin(Bin_Values'length, Bin_Values, Bin_Counts, Options); - end Histogram_Binned; - - - -- Start new page. Should only be used with pleop(). - -- plbop - procedure Begin_New_Page is - begin - plbop; - end Begin_New_Page; - - - -- This draws a box around the current viewport. - -- plbox - procedure Box_Around_Viewport - (X_Option_String : String; - X_Major_Tick_Interval : Long_Float; - X_Number_Of_Subintervals : Natural := 0; - Y_Option_String : String; - Y_Major_Tick_Interval : Long_Float; - Y_Number_Of_Subintervals : Natural) is - begin - plbox - (To_C(X_Option_String, True), X_Major_Tick_Interval, X_Number_Of_Subintervals, - To_C(Y_Option_String, True), Y_Major_Tick_Interval, Y_Number_Of_Subintervals); - end Box_Around_Viewport; - - - -- This is the 3-d analogue of plbox(). - -- plbox3 - procedure Box_Around_Viewport_3D - (X_Option_String : String; - X_Label : String := To_String(Default_Label_String); - X_Major_Tick_Interval : Long_Float := 0.0; - X_Number_Of_Subintervals : Natural := 0; - - Y_Option_String : String; - Y_Label : String := To_String(Default_Label_String); - Y_Major_Tick_Interval : Long_Float := 0.0; - Y_Number_Of_Subintervals : Natural := 0; - - Z_Option_String : String; - Z_Label : String := To_String(Default_Label_String); - Z_Major_Tick_Interval : Long_Float := 0.0; - Z_Number_Of_Subintervals : Natural := 0) is - begin - plbox3 - (To_C(X_Option_String, True), To_C(X_Label, True), X_Major_Tick_Interval, X_Number_Of_Subintervals, - To_C(Y_Option_String, True), To_C(Y_Label, True), Y_Major_Tick_Interval, Y_Number_Of_Subintervals, - To_C(Z_Option_String, True), To_C(Z_Label, True), Z_Major_Tick_Interval, Z_Number_Of_Subintervals); - end Box_Around_Viewport_3D; - - - -- Calculate world coordinates and subpage from relative device coordinates. - -- plcalc_world - procedure World_From_Relative_Coordinates - (x_Relative, y_Relative : Long_Float_0_1_Type; - x_World, y_World : out Long_Float; - Last_Window_Index : out Integer) is - begin - plcalc_world(x_Relative, y_Relative, x_World, y_World, Last_Window_Index); - end World_From_Relative_Coordinates; - - - -- Clear current subpage. - -- plclear - procedure Clear_Current_Subpage is - begin - plclear; - end Clear_Current_Subpage; - - - -- Set color, map 0. Argument is integer between 0 and 15. - -- plcol0 - procedure Set_Pen_Color(A_Color : Plot_Color_Type) is - begin - plcol0(A_Color); - end Set_Pen_Color; - - - -- Set color, map 1. Argument is a float between 0. and 1. - -- plcol1 - procedure Set_Color_Map_1(Color : Long_Float_0_1_Type) is - begin - plcol1(Color); - end Set_Color_Map_1; - - - -- Draws a contour plot from data in f(nx,ny). Is just a front-end to - -- plfcont, with a particular choice for f2eval and f2eval_data. - --- fix this ----------- Ada binding note of December 7, 2006 (JB) ------------ --- This is mostly "fixed," but calls to pltr1 (and presumably pltr2) fail. --- The subroutine pltr1 (in file plcont.c) seems to be locked in to the --- zero-based C array indexing style. For example, this line checks for array --- bounds and exits if they are not zero-based: --- if (x < 0 || x > nx - 1 || y < 0 || y > ny - 1) { --- plexit("pltr1: Invalid coordinates"); --- Setting the Ada arrays in Transformation_Data_Type to begin indexing at 0 --- prevents the above abort to happen (but forces zero-based indexing in your --- Ada arrays). --- HOWEVER, this then causes the following error: --- *** PLPLOT ERROR *** --- plfcont: indices must satisfy 1 <= kx <= lx <= nx, aborting operation --- For now, only calls to pltr0 (no mapping) do not cause problems. - - -- plcont - procedure Contour_Plot - (z : Real_Matrix; - x_Min_Index, x_Max_Index : Integer; - y_Min_Index, y_Max_Index : Integer; - Contour_Levels : Real_Vector; - Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type; - Transformation_Data : Transformation_Data_Type) is - - -- This is a good place to change from the convenient form of passing - -- the transformation data (a record) to the form required by the PLplot - -- API (a pointer). - Transformation_Data_Address : PLpointer; - begin - Transformation_Data_Address := Transformation_Data'Address; - plcont(Matrix_To_Pointers(z), z'Length(1), z'Length(2), - x_Min_Index, x_Max_Index, y_Min_Index, y_Max_Index, Contour_Levels, - Contour_Levels'Length, Transformation_Procedure_Pointer, - Transformation_Data_Address); - end Contour_Plot; - - - -- The procedure plfcont is not documented and is not part of the API. - -- However, it is a very useful capability to have available. - -- I have tried to implement it as I think was intended but this may be incorrect. - -- It appears as though the intent is to pass the arbitrarily organized - -- data (pointed to by Irregular_Data_Pointer) as a (single) pointer to a - -- 2D C-style array. Thus, for examaple, it is not possible to pass the data - -- as triples. - - -- Draws a contour plot using the function evaluator f2eval and data stored - -- by way of the f2eval_data pointer. This allows arbitrary organizations - -- of 2d array data to be used. - - -- plfcont - procedure Contour_Plot_Irregular_Data - (Function_Evaluator_Pointer : Function_Evaluator_Pointer_Type; - Irregular_Data : Real_Matrix; - x_Min_Index, x_Max_Index : Integer; - y_Min_Index, y_Max_Index : Integer; - Contour_Levels : Real_Vector; - Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type; - Transformation_Data : Transformation_Data_Type) is - - -- This is a good place to change from the convenient form of passing - -- the transformation data (a record) to the form required by the PLplot - -- API (a pointer); same for the irregularly spaced data matrix. - Transformation_Data_Address : PLpointer; - Irregular_Data_Address : PLpointer; - begin - Transformation_Data_Address := Transformation_Data'Address; - Irregular_Data_Address := Irregular_Data'Address; - - plfcont(Function_Evaluator_Pointer, Irregular_Data_Address, - Irregular_Data'Length(1), Irregular_Data'Length(2), - x_Min_Index, x_Max_Index, y_Min_Index, y_Max_Index, - Contour_Levels, Contour_Levels'Length, - Transformation_Procedure_Pointer, Transformation_Data_Address); - end Contour_Plot_Irregular_Data; - - - -- Copies state parameters from the reference stream to the current stream. - -- plcpstrm - procedure Copy_State_Parameters - (Stream_ID : Integer; - Do_Not_Copy_Device_Coordinates : Boolean) is - - PL_Do_Not_Copy_Device_Coordinates : PLBOOL; - - begin - if Do_Not_Copy_Device_Coordinates then - PL_Do_Not_Copy_Device_Coordinates := PLtrue; - else - PL_Do_Not_Copy_Device_Coordinates := PLfalse; - end if; - plcpstrm(Stream_ID, PL_Do_Not_Copy_Device_Coordinates); - end Copy_State_Parameters; - - - -- fix this - -- Converts input values from relative device coordinates to relative plot - -- coordinates. - -- pldid2pc - procedure pldid2pc_Placeholder is - begin - Put_Line("Not implemented due to lack of documentation."); - end pldid2pc_Placeholder; - - - -- fix this - -- Converts input values from relative plot coordinates to relative - -- device coordinates. - -- pldip2dc - procedure pldip2dc_Placeholder is - begin - Put_Line("Not implemented due to lack of documentation."); - end pldip2dc_Placeholder; - - - -- End a plotting session for all open streams. - -- plend - procedure End_PLplot is - begin - plend; - end End_PLplot; - - - -- End a plotting session for the current stream only. - -- plend1 - procedure End_PLplot_Current_Stream is - begin - plend1; - end End_PLplot_Current_Stream; - - - -- Simple interface for defining viewport and window. - -- plenv - procedure Set_Environment - (x_Min, x_Max, y_Min, y_Max : Long_Float; - Justification : Justification_Type; - Ax... [truncated message content] |
From: <jb...@us...> - 2008-03-21 12:10:06
|
Revision: 8307 http://plplot.svn.sourceforge.net/plplot/?rev=8307&view=rev Author: jbauck Date: 2008-03-21 05:10:06 -0700 (Fri, 21 Mar 2008) Log Message: ----------- The binding up to now had problems related to contour plots (Example 9) and index errors in the home-made range checking that is in the C calling chain from plcont.c. When the user supplied zero-based arrays to work around that problem, further problems arose in plfcont. Also, the data for mapping the contour plot coordinates was not being passed properly. This patch includes a re-write of the callbacks pltr0, pltr1, and pltr2 in Ada with C calling conventions enforced, since these procedures are called by C after about five levels of calling. The plotter data are passed by PLpointer which is System.Address, with the "shape" of the data reconstructed within the pltr? mapper. The same approach should be used with user-generated plotter mapping callback subprograms as is demonstrated in Example 9. Modified Paths: -------------- trunk/bindings/ada/plplot.adb.cmake trunk/bindings/ada/plplot.ads.cmake trunk/bindings/ada/plplot_auxiliary.adb.cmake trunk/bindings/ada/plplot_thin.adb.cmake trunk/bindings/ada/plplot_thin.ads.cmake trunk/bindings/ada/plplot_traditional.adb.cmake trunk/bindings/ada/plplot_traditional.ads.cmake Modified: trunk/bindings/ada/plplot.adb.cmake =================================================================== --- trunk/bindings/ada/plplot.adb.cmake 2008-03-21 02:21:44 UTC (rev 8306) +++ trunk/bindings/ada/plplot.adb.cmake 2008-03-21 12:10:06 UTC (rev 8307) @@ -550,10 +550,6 @@ --------- Simple Contour Plotter ------ - -- Place-holder for the transformation data which is not used here. - Transformation_Data : aliased Transformation_Data_Type - (x_Length_Minus_1 => 2, y_Length_Minus_1 => 2, z_Length_Minus_1 => 2); - procedure Simple_Contour (z : Real_Matrix; Number_Levels : Integer := 10; @@ -562,23 +558,8 @@ Title_Label : String := To_String(Default_Label_String)) is Contour_Levels : Real_Vector (0 .. Number_Levels); - Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type; begin - -- Fill up the dummy transformation data with something so we don't get warnings. - for i in Transformation_Data.xg'range loop -- use shorthand for .all on pointer - Transformation_Data.xg(i) := 0.0; - end loop; - for i in Transformation_Data.yg'range loop - Transformation_Data.yg(i) := 0.0; - end loop; - for i in Transformation_Data.zg'range loop - Transformation_Data.zg(i) := 0.0; - end loop; - - -- Point to the do-nothing transformation procedure. - Transformation_Procedure_Pointer := PLplot_Thin.pltr0'access; - -- Fill the contour vector with some levels. Calculate_Contour_Levels(Contour_Levels, Matrix_Min(z), Matrix_Max(z)); @@ -592,7 +573,7 @@ Set_Pen_Color(White); Set_Contour_Label_Parameters(0.008, 0.6, 0.1, True); Contour_Plot(z, z'First(1), z'Last(1), z'First(2), z'Last(2), - Contour_Levels, Transformation_Procedure_Pointer, Transformation_Data); + Contour_Levels, PLplot_Thin.pltr0'access, System.Null_Address); end Simple_Contour; @@ -1252,41 +1233,19 @@ -- Draws a contour plot from data in f(nx,ny). Is just a front-end to -- plfcont, with a particular choice for f2eval and f2eval_data. --- fix this ----------- Ada binding note of December 7, 2006 (JB) ------------ --- This is mostly "fixed," but calls to pltr1 (and presumably pltr2) fail. --- The subroutine pltr1 (in file plcont.c) seems to be locked in to the --- zero-based C array indexing style. For example, this line checks for array --- bounds and exits if they are not zero-based: --- if (x < 0 || x > nx - 1 || y < 0 || y > ny - 1) { --- plexit("pltr1: Invalid coordinates"); --- Setting the Ada arrays in Transformation_Data_Type to begin indexing at 0 --- prevents the above abort to happen (but forces zero-based indexing in your --- Ada arrays). --- HOWEVER, this then causes the following error: --- *** PLPLOT ERROR *** --- plfcont: indices must satisfy 1 <= kx <= lx <= nx, aborting operation --- For now, only calls to pltr0 (no mapping) do not cause problems. - - -- plcont + -- plcont (universal version using System.Address to the transformation data) procedure Contour_Plot (z : Real_Matrix; x_Min_Index, x_Max_Index : Integer; y_Min_Index, y_Max_Index : Integer; Contour_Levels : Real_Vector; Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type; - Transformation_Data : Transformation_Data_Type) is - - -- This is a good place to change from the convenient form of passing - -- the transformation data (a record) to the form required by the PLplot - -- API (a pointer). - Transformation_Data_Address : PLpointer; + Transformation_Data_Pointer : PLpointer) is begin - Transformation_Data_Address := Transformation_Data'Address; plcont(Matrix_To_Pointers(z), z'Length(1), z'Length(2), x_Min_Index, x_Max_Index, y_Min_Index, y_Max_Index, Contour_Levels, Contour_Levels'Length, Transformation_Procedure_Pointer, - Transformation_Data_Address); + Transformation_Data_Pointer); end Contour_Plot; @@ -1297,6 +1256,7 @@ -- data (pointed to by Irregular_Data_Pointer) as a (single) pointer to a -- 2D C-style array. Thus, for examaple, it is not possible to pass the data -- as triples. + -- For further conversion insight, see plcont, above. -- Draws a contour plot using the function evaluator f2eval and data stored -- by way of the f2eval_data pointer. This allows arbitrary organizations @@ -2908,8 +2868,17 @@ -- Transformation routines - -- These wrappers are necessary because Ada pointers don't like to point to - -- subroutines having non-Ada conventions (I suppose). + -- fix this These functions are redundant with those in plplot_thin. + -- This might be OK since they are now available at all levels of binding. + -- I wonder if this is approaching "wrapper bloat" since these procedures + -- get called a lot of times during the making of a contour plot. + -- The way to eliminate one level of calling would be to move the bodies + -- of pltr? from plplot_thin.adb into plplot_traditional.adb and + -- plplot.adb, then optionally eliminating the bodies from plplot_thin.adb + -- on the idea that nobody is going to use them anyway. But even if the + -- bodies were left in plplot_thin.adb, having them here would still + -- remove the extra call level. The argument for the currend arrangement is + -- easier code maintainence. -- Identity transformation. -- pltr0 Modified: trunk/bindings/ada/plplot.ads.cmake =================================================================== --- trunk/bindings/ada/plplot.ads.cmake 2008-03-21 02:21:44 UTC (rev 8306) +++ trunk/bindings/ada/plplot.ads.cmake 2008-03-21 12:10:06 UTC (rev 8307) @@ -39,6 +39,14 @@ package PLplot is + -- "Rename" some types mainly used for contour plots and the like so that + -- user programs can see them without with-ing PLplot_thin. It might be + -- good to remove "use PLplot_Thin" for clarity since it is used in only + -- a few places. + subtype PLPointer is PLplot_Thin.PLpointer; + subtype Transformation_Data_Type is Plplot_Thin.Transformation_Data_Type; + subtype Transformation_Data_Type_2 is Plplot_Thin.Transformation_Data_Type_2; + -------------------------------------------------------------------------------- -- Types and constants for thick binding -- -------------------------------------------------------------------------------- @@ -661,6 +669,8 @@ -- Draws a contour plot from data in f(nx,ny). Is just a front-end to plfcont, -- with a particular choice for f2eval and f2eval_data. + + -- plcont procedure Contour_Plot (z : Real_Matrix; @@ -668,7 +678,7 @@ y_Min_Index, y_Max_Index : Integer; Contour_Levels : Real_Vector; Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type; - Transformation_Data : Transformation_Data_Type); + Transformation_Data_Pointer : PLpointer); -- The procedure plfcont is not documented and is not part of the API. @@ -1620,8 +1630,17 @@ -- Transformation routines - -- These wrappers are necessary because Ada pointers don't like to point to - -- subroutines having non-Ada conventions (I suppose). + -- fix this These functions are redundant with those in plplot_thin. + -- This might be OK since they are now available at all levels of binding. + -- I wonder if this is approaching "wrapper bloat" since these procedures + -- get called a lot of times during the making of a contour plot. + -- The way to eliminate one level of calling would be to move the bodies + -- of pltrx from plplot_thin.adb into plplot_traditional.adb and + -- plplot.adb, then optionally eliminating the bodies from plplot_thin.adb + -- on the idea that nobody is going to use them anyway. But even if the + -- bodies were left in plplot_thin.adb, having them here would still + -- remove the extra call level. The argument for the currend arrangement is + -- easier code maintainence. -- Identity transformation. -- pltr0 @@ -1629,6 +1648,7 @@ (x_Grid, y_Grid : Long_Float; x_World, y_World : out Long_Float; Data : PLpointer); + pragma Convention(Convention => C, Entity => Plot_Transformation_0); -- Does linear interpolation from singly dimensioned coord arrays. @@ -1637,6 +1657,7 @@ (x_Grid, y_Grid : Long_Float; x_World, y_World : out Long_Float; Data_Pointer : PLpointer); + pragma Convention(Convention => C, Entity => Plot_Transformation_1); -- Does linear interpolation from doubly dimensioned coord arrays @@ -1646,6 +1667,7 @@ (x_Grid, y_Grid : Long_Float; x_World, y_World : out Long_Float; Data_Pointer : PLpointer); + pragma Convention(Convention => C, Entity => Plot_Transformation_2); Modified: trunk/bindings/ada/plplot_auxiliary.adb.cmake =================================================================== --- trunk/bindings/ada/plplot_auxiliary.adb.cmake 2008-03-21 02:21:44 UTC (rev 8306) +++ trunk/bindings/ada/plplot_auxiliary.adb.cmake 2008-03-21 12:10:06 UTC (rev 8307) @@ -107,5 +107,5 @@ end loop; return Result; end Matrix_Max; - + end PLplot_Auxiliary; Modified: trunk/bindings/ada/plplot_thin.adb.cmake =================================================================== --- trunk/bindings/ada/plplot_thin.adb.cmake 2008-03-21 02:21:44 UTC (rev 8306) +++ trunk/bindings/ada/plplot_thin.adb.cmake 2008-03-21 12:10:06 UTC (rev 8307) @@ -21,9 +21,12 @@ -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA with - PLplot_Auxiliary; + PLplot_Auxiliary, + Ada.Text_IO, + System.Address_To_Access_Conversions; use - PLplot_Auxiliary; + PLplot_Auxiliary, + Ada.Text_IO; package body PLplot_Thin is @@ -48,6 +51,8 @@ -- as an argument and returns a "proper" access variable using the method -- discussed in "Ada as a Second Language," Second Edition, by Norman H. -- Cohen, Section 19.3, for portability. This should remove GNAT dependence. + + -- Question: Will Unchecked_Access, a normal Ada feature, work instead? function Matrix_To_Pointers(x : Real_Matrix) return Long_Float_Pointer_Array is Index_Of_First_Column : Integer := x'First(2); @@ -126,4 +131,225 @@ plparseopts_local(Gnat_Argc_Access, Gnat_Argv, Mode); end plparseopts; + + -- Transformation routines + + -- pltr0, pltr1, and pltr2 had to be re-written in Ada in order to make the + -- callback work while also passing the data structure along, e.g. + -- pltr_data in the formal names below. The machinery surround this ide also + -- allows for easy user- defined plot transformation subprograms to be + -- written. + + -- Identity transformation. Re-write of pltr0 in plcont.c in Ada. + procedure pltr0 + (x, y : PLFLT; + tx, ty : out PLFLT; + pltr_data : PLplot_thin.PLpointer) is + begin + tx := x; + ty := y; + end pltr0; + + + -- Re-write of pltr1 in Ada. + procedure pltr1 + (x, y : PLFLT; + tx, ty : out PLFLT; + pltr_data : PLplot_thin.PLpointer) + is + ul, ur, vl, vr : PLINT; + du, dv : PLFLT; + xl, xr, yl, yr : PLFLT; + package Transformation_Data_Type_Address_Conversions is new System.Address_To_Access_Conversions(Transformation_Data_Type); -- temp + Transformation_Data_Pointer : Transformation_Data_Type_Address_Conversions.Object_Pointer; + nx, ny : Integer; + + begin + Transformation_Data_Pointer := Transformation_Data_Type_Address_Conversions.To_Pointer(pltr_data); + + nx := Transformation_Data_Pointer.nx; + ny := Transformation_Data_Pointer.ny; + + ul := Integer(x); + ur := ul + 1; + du := x - Long_Float(ul); + + vl := Integer(y); + vr := vl + 1; + dv := y - Long_Float(vl); + + if x < 0.0 or x > Long_Float(nx - 1) or y < 0.0 or y > Long_Float(ny - 1) then + -- Mimic (badly, probably) plexit. Don't call plend and don't abort. + -- This might be better if an exception is declared where plcont is called + -- to prevent multiple calls to this while trying to make a sinlge plot. + tx := 0.0; -- These shouldn't be used. + ty := 0.0; -- Only set them to prevent compiler warning. + Put_Line("*** PLPLOT ERROR, IMMEDIATE EXIT ***"); + Put_Line("pltr1: Invalid coordinates"); + return; -- Return to caller instead of aborting like plexit. + end if; + + xl := Transformation_Data_Pointer.xg(ul); + yl := Transformation_Data_Pointer.yg(vl); + + if ur = Transformation_Data_Pointer.nx then + tx := xl; + else + xr := Transformation_Data_Pointer.xg(ur); + tx := xl * (1.0 - du) + xr * du; + end if; + + if vr = Transformation_Data_Pointer.ny then + ty := yl; + else + yr := Transformation_Data_Pointer.yg(vr); + ty := yl * (1.0 - dv) + yr * dv; + end if; + end pltr1; + + + -- Re-write of pltr2 in Ada. + -- Does linear interpolation from doubly dimensioned coord arrays + -- (column dominant, as per normal C 2d arrays). + procedure pltr2 + (x, y : PLFLT; + tx, ty : out PLFLT; + pltr_data : PLplot_thin.PLpointer) + is + ul, ur, vl, vr : Integer; + du, dv : PLFLT; + xll, xlr, xrl, xrr : PLFLT; + yll, ylr, yrl, yrr : PLFLT; + xmin, xmax, ymin, ymax : PLFLT; + + package Transformation_Data_Type_2_Address_Conversions is new System.Address_To_Access_Conversions(Transformation_Data_Type_2); + TD : Transformation_Data_Type_2_Address_Conversions.Object_Pointer; + + begin + TD := Transformation_Data_Type_2_Address_Conversions.To_Pointer(pltr_data); + + + ul := Integer(x); + ur := ul + 1; + du := x - Long_Float(ul); + + vl := Integer(y); + vr := vl + 1; + dv := y - Long_Float(vl); + + xmin := 0.0; + xmax := Long_Float(TD.nx - 1); + ymin := 0.0; + ymax := Long_Float(TD.ny - 1); + + if x < xmin or x > xmax or y < ymin or y > ymax then + Put_Line("*** PLPLOT WARNING ***"); + Put_Line("pltr2: Invalid coordinates"); + + if x < xmin then + + if y < ymin then + tx := TD.xg(0, 0); + ty := TD.yg(0, 0); + elsif y > ymax then + tx := TD.xg(0, TD.ny - 1); + ty := TD.yg(0, TD.ny - 1); + else + xll := TD.xg(0, vl); + yll := TD.yg(0, vl); + xlr := TD.xg(0, vr); + ylr := TD.yg(0, vr); + + tx := xll * (1.0 - dv) + xlr * dv; + ty := yll * (1.0 - dv) + ylr * dv; + end if; + + elsif x > xmax then + + if y < ymin then + tx := TD.xg(TD.nx - 1, 0); + ty := TD.yg(TD.nx - 1, 0); + elsif y > ymax then + tx := TD.xg(TD.nx - 1, TD.ny - 1); + ty := TD.yg(TD.nx - 1, TD.ny - 1); + else + xll := TD.xg(TD.nx - 1, vl); + yll := TD.yg(TD.nx - 1, vl); + xlr := TD.xg(TD.nx - 1, vr); + ylr := TD.yg(TD.nx - 1, vr); + + tx := xll * (1.0 - dv) + xlr * dv; + ty := yll * (1.0 - dv) + ylr * dv; + end if; + + else + + if y < ymin then + xll := TD.xg(ul, 0); + xrl := TD.xg(ur, 0); + yll := TD.yg(ul, 0); + yrl := TD.yg(ur, 0); + + tx := xll * (1.0 - du) + xrl * du; + ty := yll * (1.0 - du) + yrl * du; + elsif y > ymax then + xlr := TD.xg(ul, TD.ny - 1); + xrr := TD.xg(ur, TD.ny - 1); + ylr := TD.yg(ul, TD.ny - 1); + yrr := TD.yg(ur, TD.ny - 1); + tx := xlr * (1.0 - du) + xrr * du; + ty := ylr * (1.0 - du) + yrr * du; + end if; + + end if; + + -- Normal case. + -- Look up coordinates in row-dominant array. + -- Have to handle right boundary specially -- if at the edge, we'd + -- better not reference the out of bounds point. + else + + xll := TD.xg(ul, vl); + yll := TD.yg(ul, vl); + + -- ur is out of bounds + if ur = TD.nx and vr < TD.ny then + xlr := TD.xg(ul, vr); + ylr := TD.yg(ul, vr); + + tx := xll * (1.0 - dv) + xlr * dv; + ty := yll * (1.0 - dv) + ylr * dv; + + -- vr is out of bounds + elsif ur < TD.nx and vr = TD.ny then + xrl := TD.xg(ur, vl); + yrl := TD.yg(ur, vl); + + tx := xll * (1.0 - du) + xrl * du; + ty := yll * (1.0 - du) + yrl * du; + + -- both ur and vr are out of bounds + elsif ur = TD.nx and vr = TD.ny then + tx := xll; + ty := yll; + + -- everything in bounds + else + xrl := TD.xg(ur, vl); + xlr := TD.xg(ul, vr); + xrr := TD.xg(ur, vr); + + yrl := TD.yg(ur, vl); + ylr := TD.yg(ul, vr); + yrr := TD.yg(ur, vr); + + tx := xll * (1.0 - du) * (1.0 - dv) + xlr * (1.0 - du) * dv + + xrl * du * (1.0 - dv) + xrr * du * dv; + + ty := yll * (1.0 - du) * (1.0 - dv) + ylr * (1.0 - du) * dv + + yrl * du * (1.0 - dv) + yrr * du * dv; + end if; + end if; + end pltr2; + end PLplot_Thin; Modified: trunk/bindings/ada/plplot_thin.ads.cmake =================================================================== --- trunk/bindings/ada/plplot_thin.ads.cmake 2008-03-21 02:21:44 UTC (rev 8306) +++ trunk/bindings/ada/plplot_thin.ads.cmake 2008-03-21 12:10:06 UTC (rev 8307) @@ -69,7 +69,7 @@ -- Types to pass 2D arrays (matrix) defined in Ada.Numerics.Generic_Real_Arrays -- (and its instances) to C functions. Have only Long_Float capability for now. type Long_Float_Pointer is access all Long_Float; - type Long_Float_Pointer_Array is array (Integer range <>) of Long_Float_Pointer; + type Long_Float_Pointer_Array is array (Integer range <>) of aliased Long_Float_Pointer; -------------------------------------------------------------------------------- @@ -89,6 +89,7 @@ -- Access-to-procedure type for Draw_Vector_Plot and its kin. type Transformation_Procedure_Pointer_Type is access procedure (x, y : PLFLT; tx, ty : out PLFLT; pltr_data : PLpointer); + pragma Convention (Convention => C, Entity => Transformation_Procedure_Pointer_Type); -- Access-to-function type for Shade_Regions (aka plshades). @@ -328,29 +329,28 @@ -- This variant record emulates PLcGrid. Use it in plvect, plcont, plfcont, -- plshade, c_plshade1, c_plshades, plfshade, plf2eval2, plf2eval, plf2evalr, -- PLcGrid and Ada counterparts thereof. - type Transformation_Data_Type (x_Length_Minus_1, y_Length_Minus_1, z_Length_Minus_1 : Positive) is + type Transformation_Data_Type (x_Last, y_Last, z_Last : Natural) is record - xg : PL_Float_Array(0 .. x_Length_Minus_1); -- no way to index from anything but 1? - yg : PL_Float_Array(0 .. y_Length_Minus_1); - zg : PL_Float_Array(0 .. z_Length_Minus_1); - nx : Positive := x_Length_Minus_1 + 1; - ny : Positive := y_Length_Minus_1 + 1; - nz : Positive := z_Length_Minus_1 + 1; + xg : PL_Float_Array(0 .. x_Last); + yg : PL_Float_Array(0 .. y_Last); + zg : PL_Float_Array(0 .. z_Last); + nx : Natural := x_Last + 1; + ny : Natural := y_Last + 1; + nz : Natural := z_Last + 1; end record; - -- PLcGrid2 is for passing (as arrays of pointers) 2d coordinate -- transformation arrays. The grid dimensions are passed for possible bounds -- checking. -- This variant record emulates PLcGrid2. - type Transformation_Data_Type_2 (x_Length_Minus_1, y_Length_Minus_1 : Positive) is + type Transformation_Data_Type_2 (x_Last, y_Last : Natural) is record - xg : PL_Float_Array_2D(0 .. x_Length_Minus_1, 0 .. y_Length_Minus_1); - yg : PL_Float_Array_2D(0 .. x_Length_Minus_1, 0 .. y_Length_Minus_1); - zg : PL_Float_Array_2D(0 .. x_Length_Minus_1, 0 .. y_Length_Minus_1); - nx : Positive := x_Length_Minus_1 + 1; - ny : Positive := y_Length_Minus_1 + 1; + xg : PL_Float_Array_2D(0 .. x_Last, 0 .. y_Last); + yg : PL_Float_Array_2D(0 .. x_Last, 0 .. y_Last); + zg : PL_Float_Array_2D(0 .. x_Last, 0 .. y_Last); + nx : Natural := x_Last + 1; + ny : Natural := y_Last + 1; end record; @@ -1570,23 +1570,35 @@ -- Transformation routines - -- Identity transformation. - procedure - pltr0(x, y : PLFLT; tx, ty : out PLFLT; pltr_data : PLpointer); - pragma Import(Ada, pltr0, "pltr0"); -- fix this; why need "Ada" convention? + -- pltr0, pltr1, and pltr2 had to be re-written in Ada in order to make the + -- callback work while also passing the data structure along, e.g. + -- pltr_data in the formal names below. The machinery surround this ide also + -- allows for easy user- defined plot transformation subprograms to be + -- written. + -- Identity transformation. Re-write of pltr0 in plcont.c in Ada. + procedure pltr0 + (x, y : PLFLT; + tx, ty : out PLFLT; + pltr_data : PLplot_thin.PLpointer); + pragma Convention (Convention => C, Entity => pltr0); - -- Does linear interpolation from singly dimensioned coord arrays. - procedure - pltr1(x, y : PLFLT; tx, ty : out PLFLT; pltr_data : PLpointer); - pragma Import(Ada, pltr1, "pltr1"); -- fix this; why need "Ada" convention? + -- Re-write of pltr1 in Ada. + procedure pltr1 + (x, y : PLFLT; + tx, ty : out PLFLT; + pltr_data : PLplot_thin.PLpointer); + pragma Convention (Convention => C, Entity => pltr1); + + -- Re-write of pltr2 in Ada. -- Does linear interpolation from doubly dimensioned coord arrays -- (column dominant, as per normal C 2d arrays). - procedure - pltr2(x, y : PLFLT; tx, ty : out PLFLT; pltr_data : PLpointer); - pragma Import(C, pltr2, "pltr2"); - + procedure pltr2 + (x, y : PLFLT; + tx, ty : out PLFLT; + pltr_data : PLplot_thin.PLpointer); + pragma Convention (Convention => C, Entity => pltr2); end PLplot_Thin; Modified: trunk/bindings/ada/plplot_traditional.adb.cmake =================================================================== --- trunk/bindings/ada/plplot_traditional.adb.cmake 2008-03-21 02:21:44 UTC (rev 8306) +++ trunk/bindings/ada/plplot_traditional.adb.cmake 2008-03-21 12:10:06 UTC (rev 8307) @@ -554,10 +554,6 @@ --------- Simple Contour Plotter ------ - -- Place-holder for the transformation data which is not used here. - Transformation_Data : aliased Transformation_Data_Type - (x_Length_Minus_1 => 2, y_Length_Minus_1 => 2, z_Length_Minus_1 => 2); - procedure Simple_Contour (z : Real_Matrix; Number_Levels : Integer := 10; @@ -566,23 +562,8 @@ Title_Label : String := To_String(Default_Label_String)) is Contour_Levels : Real_Vector (0 .. Number_Levels); - Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type; begin - -- Fill up the dummy transformation data with something so we don't get warnings. - for i in Transformation_Data.xg'range loop -- use shorthand for .all on pointer - Transformation_Data.xg(i) := 0.0; - end loop; - for i in Transformation_Data.yg'range loop - Transformation_Data.yg(i) := 0.0; - end loop; - for i in Transformation_Data.zg'range loop - Transformation_Data.zg(i) := 0.0; - end loop; - - -- Point to the do-nothing transformation procedure. - Transformation_Procedure_Pointer := PLplot_Thin.pltr0'access; - -- Fill the contour vector with some levels. Calculate_Contour_Levels(Contour_Levels, Matrix_Min(z), Matrix_Max(z)); @@ -596,7 +577,7 @@ plcol0(White); pl_setcontlabelparam(0.008, 0.6, 0.1, True); plcont(z, z'First(1), z'Last(1), z'First(2), z'Last(2), - Contour_Levels, Transformation_Procedure_Pointer, Transformation_Data); + Contour_Levels, PLplot_Thin.pltr0'access, System.Null_Address); end Simple_Contour; @@ -1242,41 +1223,19 @@ -- Draws a contour plot from data in f(nx,ny). Is just a front-end to -- plfcont, with a particular choice for f2eval and f2eval_data. --- fix this ----------- Ada binding note of December 7, 2006 (JB) ------------ --- This is mostly "fixed," but calls to pltr1 (and presumably pltr2) fail. --- The subroutine pltr1 (in file plcont.c) seems to be locked in to the --- zero-based C array indexing style. For example, this line checks for array --- bounds and exits if they are not zero-based: --- if (x < 0 || x > nx - 1 || y < 0 || y > ny - 1) { --- plexit("pltr1: Invalid coordinates"); --- Setting the Ada arrays in Transformation_Data_Type to begin indexing at 0 --- prevents the above abort to happen (but forces zero-based indexing in your --- Ada arrays). --- HOWEVER, this then causes the following error: --- *** PLPLOT ERROR *** --- plfcont: indices must satisfy 1 <= kx <= lx <= nx, aborting operation --- For now, only calls to pltr0 (no mapping) do not cause problems. - - -- plcont + -- plcont (universal version using System.Address to the transformation data) procedure plcont (z : Real_Matrix; x_Min_Index, x_Max_Index : Integer; y_Min_Index, y_Max_Index : Integer; Contour_Levels : Real_Vector; Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type; - Transformation_Data : Transformation_Data_Type) is - - -- This is a good place to change from the convenient form of passing - -- the transformation data (a record) to the form required by the PLplot - -- API (a pointer). - Transformation_Data_Address : PLpointer; + Transformation_Data_Pointer : PLpointer) is begin - Transformation_Data_Address := Transformation_Data'Address; PLplot_Thin.plcont(Matrix_To_Pointers(z), z'Length(1), z'Length(2), x_Min_Index, x_Max_Index, y_Min_Index, y_Max_Index, Contour_Levels, Contour_Levels'Length, Transformation_Procedure_Pointer, - Transformation_Data_Address); + Transformation_Data_Pointer); end plcont; @@ -1287,6 +1246,7 @@ -- data (pointed to by Irregular_Data_Pointer) as a (single) pointer to a -- 2D C-style array. Thus, for examaple, it is not possible to pass the data -- as triples. + -- For further conversion insight, see plcont, above. -- Draws a contour plot using the function evaluator f2eval and data stored -- by way of the f2eval_data pointer. This allows arbitrary organizations @@ -2770,8 +2730,17 @@ -- Transformation routines - -- These wrappers are necessary because Ada pointers don't like to point to - -- subroutines having non-Ada conventions (I suppose). + -- fix this These functions are redundant with those in plplot_thin. + -- This might be OK since they are now available at all levels of binding. + -- I wonder if this is approaching "wrapper bloat" since these procedures + -- get called a lot of times during the making of a contour plot. + -- The way to eliminate one level of calling would be to move the bodies + -- of pltr? from plplot_thin.adb into plplot_traditional.adb and + -- plplot.adb, then optionally eliminating the bodies from plplot_thin.adb + -- on the idea that nobody is going to use them anyway. But even if the + -- bodies were left in plplot_thin.adb, having them here would still + -- remove the extra call level. The argument for the currend arrangement is + -- easier code maintainence. -- Identity transformation. procedure pltr0 Modified: trunk/bindings/ada/plplot_traditional.ads.cmake =================================================================== --- trunk/bindings/ada/plplot_traditional.ads.cmake 2008-03-21 02:21:44 UTC (rev 8306) +++ trunk/bindings/ada/plplot_traditional.ads.cmake 2008-03-21 12:10:06 UTC (rev 8307) @@ -39,6 +39,14 @@ package PLplot_Traditional is + -- "Rename" some types mainly used for contour plots and the like so that + -- user programs can see them without with-ing PLplot_thin. It might be + -- good to remove "use PLplot_Thin" for clarity since it is used in only + -- a few places. + subtype PLPointer is PLplot_Thin.PLpointer; + subtype Transformation_Data_Type is Plplot_Thin.Transformation_Data_Type; + subtype Transformation_Data_Type_2 is Plplot_Thin.Transformation_Data_Type_2; + -------------------------------------------------------------------------------- -- Types and constants for thick binding -- -------------------------------------------------------------------------------- @@ -646,13 +654,16 @@ -- Draws a contour plot from data in f(nx,ny). Is just a front-end to plfcont, -- with a particular choice for f2eval and f2eval_data. + + + -- plcont procedure plcont (z : Real_Matrix; x_Min_Index, x_Max_Index : Integer; y_Min_Index, y_Max_Index : Integer; Contour_Levels : Real_Vector; Transformation_Procedure_Pointer : Transformation_Procedure_Pointer_Type; - Transformation_Data : Transformation_Data_Type); + Transformation_Data_Pointer : PLpointer); -- The procedure plfcont is not documented and is not part of the API. @@ -1473,14 +1484,24 @@ -- Transformation routines - -- These wrappers are necessary because Ada pointers don't like to point to - -- subroutines having non-Ada conventions (I suppose). + -- fix this These functions are redundant with those in plplot_thin. + -- This might be OK since they are now available at all levels of binding. + -- I wonder if this is approaching "wrapper bloat" since these procedures + -- get called a lot of times during the making of a contour plot. + -- The way to eliminate one level of calling would be to move the bodies + -- of pltrx from plplot_thin.adb into plplot_traditional.adb and + -- plplot.adb, then optionally eliminating the bodies from plplot_thin.adb + -- on the idea that nobody is going to use them anyway. But even if the + -- bodies were left in plplot_thin.adb, having them here would still + -- remove the extra call level. The argument for the currend arrangement is + -- easier code maintainence. -- Identity transformation. procedure pltr0 (x_Grid, y_Grid : Long_Float; x_World, y_World : out Long_Float; Data : PLpointer); + pragma Convention(Convention => C, Entity => pltr0); -- Does linear interpolation from singly dimensioned coord arrays. @@ -1488,6 +1509,7 @@ (x_Grid, y_Grid : Long_Float; x_World, y_World : out Long_Float; Data_Pointer : PLpointer); + pragma Convention(Convention => C, Entity => pltr1); -- Does linear interpolation from doubly dimensioned coord arrays @@ -1496,6 +1518,7 @@ (x_Grid, y_Grid : Long_Float; x_World, y_World : out Long_Float; Data_Pointer : PLpointer); + pragma Convention(Convention => C, Entity => pltr2); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jb...@us...> - 2008-07-04 22:54:40
|
Revision: 8505 http://plplot.svn.sourceforge.net/plplot/?rev=8505&view=rev Author: jbauck Date: 2008-07-04 15:54:49 -0700 (Fri, 04 Jul 2008) Log Message: ----------- Fixed the color problems in Ada examples x05.adb and xthick05.adb by removing cruft from the bindings placed there by space aliens. Modified Paths: -------------- trunk/bindings/ada/plplot.adb.cmake trunk/bindings/ada/plplot_traditional.adb.cmake Modified: trunk/bindings/ada/plplot.adb.cmake =================================================================== --- trunk/bindings/ada/plplot.adb.cmake 2008-07-04 18:41:41 UTC (rev 8504) +++ trunk/bindings/ada/plplot.adb.cmake 2008-07-04 22:54:49 UTC (rev 8505) @@ -1713,10 +1713,8 @@ Number_Of_Bins : Positive; -- equal-sized, between Data_Min and Data_Max Options : Integer) is -- Options are not defined in plplot.h. begin - Set_Pen_Color(White); plhist (Data'length, Data, Data_Min, Data_Max, Number_Of_Bins, Options); - Set_Pen_Color(White); end Histogram_Unbinned; Modified: trunk/bindings/ada/plplot_traditional.adb.cmake =================================================================== --- trunk/bindings/ada/plplot_traditional.adb.cmake 2008-07-04 18:41:41 UTC (rev 8504) +++ trunk/bindings/ada/plplot_traditional.adb.cmake 2008-07-04 22:54:49 UTC (rev 8505) @@ -1657,10 +1657,8 @@ Number_Of_Bins : Positive; -- equal-sized, between Data_Min and Data_Max Options : Integer) is -- Options are not defined in plplot.h. begin - plcol0(White); PLplot_Thin.plhist (Data'length, Data, Data_Min, Data_Max, Number_Of_Bins, Options); - plcol0(White); end plhist; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |