|
From: <jb...@us...> - 2013-09-24 10:27:22
|
Revision: 12523
http://sourceforge.net/p/plplot/code/12523
Author: jbauck
Date: 2013-09-24 10:27:16 +0000 (Tue, 24 Sep 2013)
Log Message:
-----------
Update Ada bindings and examples 16 and 33 for plcolorbar capability. Also add support for plscmap1_range and plgcmap1_range.
Modified Paths:
--------------
trunk/bindings/ada/plplot.adb
trunk/bindings/ada/plplot.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
trunk/examples/ada/x16a.adb
trunk/examples/ada/x33a.adb
trunk/examples/ada/xthick16a.adb
trunk/examples/ada/xthick33a.adb
Modified: trunk/bindings/ada/plplot.adb
===================================================================
--- trunk/bindings/ada/plplot.adb 2013-09-24 05:27:13 UTC (rev 12522)
+++ trunk/bindings/ada/plplot.adb 2013-09-24 10:27:16 UTC (rev 12523)
@@ -1,8 +1,8 @@
-- $Id$
--- Thick Ada binding to PLplot
+-- Thick Ada binding to PLplot
--- Copyright (C) 2006-2011 Jerry Bauck
+-- Copyright (C) 2006-2013 Jerry Bauck
-- This file is part of PLplot.
@@ -1909,7 +1909,7 @@
X_Offset, Y_Offset : Long_Float;
Plot_Area_Width : Long_Float;
Background_Color, Bounding_Box_Color : Plot_Color_Type;
- Bounding_Box_Style : Legend_Flag_Type;
+ Bounding_Box_Style : Line_Style_Type;
Number_Rows, Number_Columns : Integer;
Entry_Options : Integer_Array_1D;
Text_Offset, Text_Scale, Text_Spacing : Long_Float;
@@ -1931,7 +1931,7 @@
PL_Label_Text, PL_Symbols : PL_Legend_String_Array(Label_Text'range);
C_Legend_String_Array : array(Label_Text'range) of PL_Legend_String;
C_Symbols_String_Array : array(Symbols'range) of PL_Legend_String;
- Dum_Text : Legend_String_Array_Type(Label_Text'range);
+ Dum_Text : Legend_String_Array_Type(Label_Text'range); --Could be a single unbounded string.
begin
-- Check that all array lengths in the argument list are the same.
L := Entry_Options'length;
@@ -1997,6 +1997,100 @@
end Create_Legend;
+ -- Routine for drawing continous colour legends
+ -- plcolorbar
+ procedure Create_Colorbar
+ (Colorbar_Width, Colorbar_Height : out Long_Float;
+ Options, Position : Integer;
+ X_Offset, Y_Offset : Long_Float;
+ X_Length, Y_Length : Long_Float;
+ Background_Color, Bounding_Box_Color : Plot_Color_Type;
+ Bounding_Box_Style : Line_Style_Type;
+ Low_Cap_Color, High_Cap_Color : Long_Float;
+ Contour_Color_For_Shade : Plot_Color_Type;
+ Contour_Width_For_Shade : Long_Float;
+ Label_Options : Integer_Array_1D;
+ Label_Text : Legend_String_Array_Type;
+ Axis_Options : Legend_String_Array_Type;
+ Tick_Spacing : Real_Vector;
+ Number_Subticks : Integer_Array_1D;
+ Number_Values : Integer_Array_1D;
+ Values : Real_Matrix)
+ is
+ Number_Labels : Integer := Label_Options'length;
+ Number_Axes : Integer := Axis_Options'length;
+ PL_Label_Text : PL_Legend_String_Array(Label_Text'range);
+ C_Legend_String_Array : array(Label_Text'range) of PL_Legend_String;
+ PL_Axis_Options : PL_Legend_String_Array(Axis_Options'range);
+ C_Axis_Options_String_Array : array(Axis_Options'range) of PL_Legend_String;
+ Dum_Text : Legend_String_Array_Type(Label_Text'range);
+ PL_Values : Long_Float_Pointer_Array(values'range(2));
+ begin
+ -- Check some array lengths.
+ if Number_Labels /= Label_Text'length then
+ Put_Line("*** WARNING: Mismatched array lengths at plcolorbar labels");
+ end if;
+ if Number_Axes /= Tick_Spacing'length or Number_Axes /= Number_Subticks'length
+ or Number_Axes /= Values'length(1) then
+ Put_Line("*** WARNING: Mismatched array lengths at plcolorbar values");
+ end if;
+
+ -- Adapt Label_Text and Axis_Options to C. See the comment at Create_Stripchart.
+ -- Adapt Label_Text first.
+ for I in Label_Text'range loop
+
+ -- Check length and adjust if necessary.
+ if Length(Label_Text(I)) >= Max_Legend_Label_Length then
+ Put_Line("*** Warning: Colorbar label was truncated to"
+ & Integer'Image(Max_Legend_Label_Length) & " characters. ***");
+ Dum_Text(I) := Head(Label_Text(I), Max_Legend_Label_Length);
+ else
+ Dum_Text(I) := Label_Text(I);
+ end if;
+
+ -- Make the C-style string with null character and spaces immediately after the text.
+ C_Legend_String_Array(I) := To_C(To_String(Dum_Text(I)
+ & Character'val(0)
+ & (Max_Legend_Label_Length - Length(Dum_Text(I))) * " "), False);
+
+ -- Set the I-th pointer in the array of pointers.
+ PL_Label_Text(I) := C_Legend_String_Array(I)'Address;
+ end loop;
+
+ -- Adapt Axis_Options next.
+ for I in Axis_Options'range loop
+
+ -- Check length and adjust if necessary.
+ if Length(Axis_Options(I)) >= Max_Legend_Label_Length then
+ Put_Line("*** Warning: Colorbar asix options label was truncated to"
+ & Integer'Image(Max_Legend_Label_Length) & " characters. ***");
+ Dum_Text(I) := Head(Axis_Options(I), Max_Legend_Label_Length);
+ else
+ Dum_Text(I) := Axis_Options(I);
+ end if;
+
+ -- Make the C-style string with null character and spaces immediately after the text.
+ C_Axis_Options_String_Array(I) := To_C(To_String(Dum_Text(I)
+ & Character'val(0)
+ & (Max_Legend_Label_Length - Length(Dum_Text(I))) * " "), False);
+
+ -- Set the I-th pointer in the array of pointers.
+ PL_Axis_Options(I) := C_Axis_Options_String_Array(I)'Address;
+ end loop;
+
+ -- Adapt values in a similar way as Label_Text: make an array of pointers to Real_Vector.
+ -- We need to transpose because we present the Values matrix to the user as described in the
+ -- PLplot documentation for plcolorbar as rows indexing axes and columns indexing the axis
+ -- values, and Matrix_To_Pointers wants things the other way.
+ PL_Values := Matrix_To_Pointers(PLplot_Thin.PL_Transpose(Values));
+ PLplot_Thin.plcolorbar(Colorbar_Width, Colorbar_Height, Options, Position, X_Offset,
+ Y_Offset, X_Length, Y_Length, Background_Color, Bounding_Box_Color, Bounding_Box_Style,
+ Low_Cap_Color, High_Cap_Color, Contour_Color_For_Shade, Contour_Width_For_Shade,
+ Number_Labels, Label_Options, PL_Label_Text, Number_Axes,
+ PL_Axis_Options, Tick_Spacing, Number_Subticks, Number_Values, PL_Values);
+ end Create_Colorbar;
+
+
-- Sets position of the light source
-- pllightsource
procedure Set_Light_Source
@@ -2562,6 +2656,22 @@
begin
plscmap1n(Number_Of_Colors);
end Set_Number_Of_Colors_In_Color_Map_1;
+
+
+ -- Set the color map 1 range used in continuous plots.
+ -- plscmap1_range
+ procedure Set_Color_Map_1_Range(Min_Color, Max_Color : Long_Float) is
+ begin
+ plscmap1_range(Min_Color, Max_Color);
+ end Set_Color_Map_1_Range;
+
+
+ -- Get the color map 1 range used in continuous plots
+ -- plgcmap1_range
+ procedure Get_Color_Map_1_Range(Min_Color : out Long_Float; Max_Color : out Long_Float) is
+ begin
+ plgcmap1_range(Min_Color, Max_Color);
+ end Get_Color_Map_1_Range;
-- Set a given color from color map 0 by 8 bit RGB value
Modified: trunk/bindings/ada/plplot.ads
===================================================================
--- trunk/bindings/ada/plplot.ads 2013-09-24 05:27:13 UTC (rev 12522)
+++ trunk/bindings/ada/plplot.ads 2013-09-24 10:27:16 UTC (rev 12523)
@@ -2,7 +2,7 @@
-- Thick Ada binding to PLplot
--- Copyright (C) 2006-2011 Jerry Bauck
+-- Copyright (C) 2006-2013 Jerry Bauck
-- This file is part of PLplot.
@@ -201,28 +201,42 @@
Legend_Row_Major : constant Legend_Flag_Type := PL_Legend_Row_Major;
-- Flags for plcolorbar (duplicated from plplot_thin.ads)
- PL_Colorbar_Label_Left : constant Colorbar_Flag_Type := 1;
- PL_Colorbar_Label_Right : constant Colorbar_Flag_Type := 2;
- PL_Colorbar_Label_Top : constant Colorbar_Flag_Type := 4;
- PL_Colorbar_Label_Bottom : constant Colorbar_Flag_Type := 8;
- PL_Colorbar_Image : constant Colorbar_Flag_Type := 16;
- PL_Colorbar_Shade : constant Colorbar_Flag_Type := 32;
- PL_Colorbar_Gradient : constant Colorbar_Flag_Type := 64;
- PL_Colorbar_Cap_Low : constant Colorbar_Flag_Type := 128;
- PL_Colorbar_Cap_High : constant Colorbar_Flag_Type := 256;
- PL_Colorbar_Shade_Label : constant Colorbar_Flag_Type := 512;
+ PL_Colorbar_Label_Left : constant Colorbar_Flag_Type := 1;
+ PL_Colorbar_Label_Right : constant Colorbar_Flag_Type := 2;
+ PL_Colorbar_Label_Top : constant Colorbar_Flag_Type := 4;
+ PL_Colorbar_Label_Bottom : constant Colorbar_Flag_Type := 8;
+ PL_Colorbar_Image : constant Colorbar_Flag_Type := 16;
+ PL_Colorbar_Shade : constant Colorbar_Flag_Type := 32;
+ PL_Colorbar_Gradient : constant Colorbar_Flag_Type := 64;
+ PL_Colorbar_Cap_None : constant Colorbar_Flag_Type := 128;
+ PL_Colorbar_Cap_Low : constant Colorbar_Flag_Type := 256;
+ PL_Colorbar_Cap_High : constant Colorbar_Flag_Type := 512;
+ PL_Colorbar_Shade_Label : constant Colorbar_Flag_Type := 1024;
+ PL_Colorbar_Orient_Right : constant Colorbar_Flag_Type := 2048;
+ PL_Colorbar_Orient_Top : constant Colorbar_Flag_Type := 4096;
+ PL_Colorbar_Orient_Left : constant Colorbar_Flag_Type := 8192;
+ PL_Colorbar_Orient_Bottom : constant Colorbar_Flag_Type := 16384;
+ PL_Colorbar_Background : constant Colorbar_Flag_Type := 32768;
+ PL_Colorbar_Bounding_Box : constant Colorbar_Flag_Type := 65536;
-- Renamed flags for plcolorbar
- Colorbar_Label_Left : constant Colorbar_Flag_Type := PL_Colorbar_Label_Left;
- Colorbar_Label_Right : constant Colorbar_Flag_Type := PL_Colorbar_Label_Right;
- Colorbar_Label_Top : constant Colorbar_Flag_Type := PL_Colorbar_Label_Top;
- Colorbar_Label_Bottom : constant Colorbar_Flag_Type := PL_Colorbar_Label_Bottom;
- Colorbar_Image : constant Colorbar_Flag_Type := PL_Colorbar_Image;
- Colorbar_Shade : constant Colorbar_Flag_Type := PL_Colorbar_Shade;
- Colorbar_Gradient : constant Colorbar_Flag_Type := PL_Colorbar_Gradient;
- Colorbar_Cap_Low : constant Colorbar_Flag_Type := PL_Colorbar_Cap_Low;
- Colorbar_Cap_High : constant Colorbar_Flag_Type := PL_Colorbar_Cap_High;
- Colorbar_Shade_Label : constant Colorbar_Flag_Type := PL_Colorbar_Shade_Label;
+ Colorbar_Label_Left : constant Colorbar_Flag_Type := PL_Colorbar_Label_Left;
+ Colorbar_Label_Right : constant Colorbar_Flag_Type := PL_Colorbar_Label_Right;
+ Colorbar_Label_Top : constant Colorbar_Flag_Type := PL_Colorbar_Label_Top;
+ Colorbar_Label_Bottom : constant Colorbar_Flag_Type := PL_Colorbar_Label_Bottom;
+ Colorbar_Image : constant Colorbar_Flag_Type := PL_Colorbar_Image;
+ Colorbar_Shade : constant Colorbar_Flag_Type := PL_Colorbar_Shade;
+ Colorbar_Gradient : constant Colorbar_Flag_Type := PL_Colorbar_Gradient;
+ Colorbar_Cap_None : constant Colorbar_Flag_Type := PL_Colorbar_Cap_None;
+ Colorbar_Cap_Low : constant Colorbar_Flag_Type := PL_Colorbar_Cap_Low;
+ Colorbar_Cap_High : constant Colorbar_Flag_Type := PL_Colorbar_Cap_High;
+ Colorbar_Shade_Label : constant Colorbar_Flag_Type := PL_Colorbar_Shade_Label;
+ Colorbar_Orient_Right : constant Colorbar_Flag_Type := PL_Colorbar_Orient_Right;
+ Colorbar_Orient_Top : constant Colorbar_Flag_Type := PL_Colorbar_Orient_Top;
+ Colorbar_Orient_Left : constant Colorbar_Flag_Type := PL_Colorbar_Orient_Left;
+ Colorbar_Orient_Bottom : constant Colorbar_Flag_Type := PL_Colorbar_Orient_Bottom;
+ Colorbar_Background : constant Colorbar_Flag_Type := PL_Colorbar_Background;
+ Colorbar_Bounding_Box : constant Colorbar_Flag_Type := PL_Colorbar_Bounding_Box;
-- Justification for plots
subtype Justification_Type is Integer range -1..2;
@@ -1299,7 +1313,7 @@
X_Offset, Y_Offset : Long_Float;
Plot_Area_Width : Long_Float;
Background_Color, Bounding_Box_Color : Plot_Color_Type;
- Bounding_Box_Style : Legend_Flag_Type;
+ Bounding_Box_Style : Line_Style_Type;
Number_Rows, Number_Columns : Integer;
Entry_Options : Integer_Array_1D;
Text_Offset, Text_Scale, Text_Spacing : Long_Float;
@@ -1317,6 +1331,27 @@
Symbols : Legend_String_Array_Type);
+ -- Routine for drawing continous colour legends
+ -- plcolorbar
+ procedure Create_Colorbar
+ (Colorbar_Width, Colorbar_Height : out Long_Float;
+ Options, Position : Integer;
+ X_Offset, Y_Offset : Long_Float;
+ X_Length, Y_Length : Long_Float;
+ Background_Color, Bounding_Box_Color : Plot_Color_Type;
+ Bounding_Box_Style : Line_Style_Type;
+ Low_Cap_Color, High_Cap_Color : Long_Float;
+ Contour_Color_For_Shade : Plot_Color_Type;
+ Contour_Width_For_Shade : Long_Float;
+ Label_Options : Integer_Array_1D;
+ Label_Text : Legend_String_Array_Type;
+ Axis_Options : Legend_String_Array_Type;
+ Tick_Spacing : Real_Vector;
+ Number_Subticks : Integer_Array_1D;
+ Number_Values : Integer_Array_1D;
+ Values : Real_Matrix);
+
+
-- Sets position of the light source
-- pllightsource
procedure Set_Light_Source
@@ -1639,6 +1674,16 @@
procedure Set_Number_Of_Colors_In_Color_Map_1(Number_Of_Colors : Integer);
+ -- Set the color map 1 range used in continuous plots.
+ -- plscmap1_range
+ procedure Set_Color_Map_1_Range(Min_Color, Max_Color : Long_Float);
+
+
+ -- Get the color map 1 range used in continuous plots
+ -- plgcmap1_range
+ procedure Get_Color_Map_1_Range(Min_Color, Max_Color : out Long_Float);
+
+
-- Set a given color from color map 0 by 8 bit RGB value
-- plscol0
procedure Set_One_Color_Map_0
Modified: trunk/bindings/ada/plplot_thin.adb
===================================================================
--- trunk/bindings/ada/plplot_thin.adb 2013-09-24 05:27:13 UTC (rev 12522)
+++ trunk/bindings/ada/plplot_thin.adb 2013-09-24 10:27:16 UTC (rev 12523)
@@ -65,6 +65,22 @@
end Matrix_To_Pointers;
+ --------------------------------------------------------------------------------
+ -- Transpose a Matrix. --
+ --------------------------------------------------------------------------------
+
+ function PL_Transpose(A : Real_Matrix) return Real_Matrix is
+ B : Real_Matrix(A'range(2), A'range(1));
+ begin
+ for i in A'range(1) loop
+ for j in A'range(2) loop
+ B(j, i) := A(i, j);
+ end loop;
+ end loop;
+ return B;
+ end PL_Transpose;
+
+
--------------------------------------------------------------------------------
-- Functions for use from C or C++ only --
-- (Not really ;). --
Modified: trunk/bindings/ada/plplot_thin.ads
===================================================================
--- trunk/bindings/ada/plplot_thin.ads 2013-09-24 05:27:13 UTC (rev 12522)
+++ trunk/bindings/ada/plplot_thin.ads 2013-09-24 10:27:16 UTC (rev 12523)
@@ -80,6 +80,13 @@
--------------------------------------------------------------------------------
+-- Transpose a Matrix. --
+--------------------------------------------------------------------------------
+
+ function PL_Transpose(A : Real_Matrix) return Real_Matrix;
+
+
+--------------------------------------------------------------------------------
-- PLplot-specific things --
--------------------------------------------------------------------------------
@@ -1048,24 +1055,34 @@
PL_Legend_Row_Major : constant Legend_Flag_Type := 128;
-- Colorbar characteristics are chosen by adding flag values.
- subtype Colorbar_Flag_Type is Integer
- range 1 .. 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 + 512 ;
+ subtype Colorbar_Flag_Type is Integer range 1 .. 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 +
+ 512 + 1024 + 2048 + 4096 + 8192 + 16384 + 32768 + 65536;
-- Flags for plcolorbar
- PL_Colorbar_Label_Left : constant Integer := 1;
- PL_Colorbar_Label_Right : constant Integer := 2;
- PL_Colorbar_Label_Top : constant Integer := 4;
- PL_Colorbar_Label_Bottom : constant Integer := 8;
- PL_Colorbar_Image : constant Integer := 16;
- PL_Colorbar_Shade : constant Integer := 32;
- PL_Colorbar_Gradient : constant Integer := 64;
- PL_Colorbar_Cap_Low : constant Integer := 128;
- PL_Colorbar_Cap_High : constant Integer := 256;
- PL_Colorbar_Shade_Label : constant Integer := 512;
+ PL_Colorbar_Label_Left : constant Colorbar_Flag_Type := 1;
+ PL_Colorbar_Label_Right : constant Colorbar_Flag_Type := 2;
+ PL_Colorbar_Label_Top : constant Colorbar_Flag_Type := 4;
+ PL_Colorbar_Label_Bottom : constant Colorbar_Flag_Type := 8;
+ PL_Colorbar_Image : constant Colorbar_Flag_Type := 16;
+ PL_Colorbar_Shade : constant Colorbar_Flag_Type := 32;
+ PL_Colorbar_Gradient : constant Colorbar_Flag_Type := 64;
+ PL_Colorbar_Cap_Low : constant Colorbar_Flag_Type := 256;
+ PL_Colorbar_Cap_High : constant Colorbar_Flag_Type := 512;
+ PL_Colorbar_Shade_Label : constant Colorbar_Flag_Type := 1024;
+ PL_Colorbar_Orient_Right : constant Colorbar_Flag_Type := 2048;
+ PL_Colorbar_Orient_Top : constant Colorbar_Flag_Type := 4096;
+ PL_Colorbar_Orient_Left : constant Colorbar_Flag_Type := 8192;
+ PL_Colorbar_Orient_Bottom : constant Colorbar_Flag_Type := 16384;
+ PL_Colorbar_Background : constant Colorbar_Flag_Type := 32768;
+ PL_Colorbar_Bounding_Box : constant Colorbar_Flag_Type := 65536;
+ -- Flags for drawing mode
+ PL_Drawmode_Unknown : constant Integer := 0;
+ PL_Drawmode_Default : constant Integer := 1;
+ PL_Drawmode_Replace : constant Integer := 2;
+ PL_Drawmode_Xor : constant Integer := 4;
-- Routine for drawing discrete line, symbol, or cmap0 legends
-
procedure
pllegend
(p_legend_width : out PLFLT; p_legend_height : out PLFLT;
@@ -1088,15 +1105,19 @@
-- Routine for drawing continous colour legends
- -- procedure
- -- plcolorbar
- -- (PLINT position, PLINT opt,
- -- PLFLT x, PLFLT y, PLFLT length, PLFLT width,
- -- PLINT cont_color, PLINT cont_width,
- -- PLFLT ticks, PLINT sub_ticks,
- -- const char *axis_opts, const char *label,
- -- PLINT n_colors, PLFLT *colors, PLFLT *values);
- -- pragma Import(C, plcolorbar, "c_pllegend");
+ procedure
+ plcolorbar
+ (p_colorbar_width : out PLFLT; p_colorbar_height : out PLFLT;
+ opt : PLINT; position : PLINT; x : PLFLT; y : PLFLT;
+ x_length : PLFLT; y_length : PLFLT;
+ bg_color : PLINT; bb_color : PLINT; bb_style : PLINT;
+ low_cap_color : PLFLT; high_cap_color : PLFLT;
+ cont_color : PLINT; cont_width : PLFLT;
+ n_labels : PLINT; label_opts : PL_Integer_Array; labels : PL_Legend_String_Array;
+ n_axes : PLINT; axis_opts : PL_Legend_String_Array;
+ ticks : PL_Float_Array; sub_ticks : PL_Integer_Array;
+ n_values : PL_Integer_Array; values : Long_Float_Pointer_Array);
+ pragma Import(C, plcolorbar, "c_plcolorbar");
-- Sets position of the light source
@@ -1395,6 +1416,20 @@
pragma Import(C, plscmap1n, "c_plscmap1n");
+ -- Set the color map 1 range used in continuous plots.
+
+ procedure
+ plscmap1_range(min_color : PLFLT; max_color : PLFLT);
+ pragma Import(C, plscmap1_range, "c_plscmap1_range");
+
+
+ -- Get the color map 1 range used in continuous plots
+
+ procedure
+ plgcmap1_range(min_color, max_color : out PLFLT);
+ pragma Import(C, plgcmap1_range, "c_plgcmap1_range");
+
+
-- Set a given color from color map 0 by 8 bit RGB value
procedure
Modified: trunk/bindings/ada/plplot_traditional.adb
===================================================================
--- trunk/bindings/ada/plplot_traditional.adb 2013-09-24 05:27:13 UTC (rev 12522)
+++ trunk/bindings/ada/plplot_traditional.adb 2013-09-24 10:27:16 UTC (rev 12523)
@@ -2,7 +2,7 @@
-- Ada binding to PLplot using the traditional PLplot subprogram names
--- Copyright (C) 2006-2011 Jerry Bauck
+-- Copyright (C) 2006-2013 Jerry Bauck
-- This file is part of PLplot.
@@ -1840,7 +1840,7 @@
X_Offset, Y_Offset : Long_Float;
Plot_Area_Width : Long_Float;
Background_Color, Bounding_Box_Color : Plot_Color_Type;
- Bounding_Box_Style : Legend_Flag_Type;
+ Bounding_Box_Style : Line_Style_Type;
Number_Rows, Number_Columns : Integer;
Entry_Options : Integer_Array_1D;
Text_Offset, Text_Scale, Text_Spacing : Long_Float;
@@ -1888,7 +1888,7 @@
Dum_Text(I) := Label_Text(I);
end if;
- -- Make the C-style string with null character immediately after the text.
+ -- Make the C-style string with null character and spaces immediately after the text.
C_Legend_String_Array(I) := To_C(To_String(Dum_Text(I)
& Character'val(0)
& (Max_Legend_Label_Length - Length(Dum_Text(I))) * " "), False);
@@ -1909,7 +1909,7 @@
Dum_Text(I) := Symbols(I);
end if;
- -- Make the C-style string with null character immediately after the text.
+ -- Make the C-style string with null character and spaces immediately after the text.
C_Symbols_String_Array(I) := To_C(To_String(Dum_Text(I)
& Character'val(0)
& (Max_Legend_Label_Length - Length(Dum_Text(I))) * " "), False);
@@ -1928,6 +1928,99 @@
end pllegend;
+ -- Routine for drawing continous colour legends
+ procedure plcolorbar
+ (Colorbar_Width, Colorbar_Height : out Long_Float;
+ Options, Position : Integer;
+ X_Offset, Y_Offset : Long_Float;
+ X_Length, Y_Length : Long_Float;
+ Background_Color, Bounding_Box_Color : Plot_Color_Type;
+ Bounding_Box_Style : Line_Style_Type;
+ Low_Cap_Color, High_Cap_Color : Long_Float;
+ Contour_Color_For_Shade : Plot_Color_Type;
+ Contour_Width_For_Shade : Long_Float;
+ Label_Options : Integer_Array_1D;
+ Label_Text : Legend_String_Array_Type;
+ Axis_Options : Legend_String_Array_Type;
+ Tick_Spacing : Real_Vector;
+ Number_Subticks : Integer_Array_1D;
+ Number_Values : Integer_Array_1D;
+ Values : Real_Matrix)
+ is
+ Number_Labels : Integer := Label_Options'length;
+ Number_Axes : Integer := Axis_Options'length;
+ PL_Label_Text : PL_Legend_String_Array(Label_Text'range);
+ C_Legend_String_Array : array(Label_Text'range) of PL_Legend_String;
+ PL_Axis_Options : PL_Legend_String_Array(Axis_Options'range);
+ C_Axis_Options_String_Array : array(Axis_Options'range) of PL_Legend_String;
+ Dum_Text : Legend_String_Array_Type(Label_Text'range);
+ PL_Values : Long_Float_Pointer_Array(values'range(2));
+ begin
+ -- Check some array lengths.
+ if Number_Labels /= Label_Text'length then
+ Put_Line("*** WARNING: Mismatched array lengths at plcolorbar labels");
+ end if;
+ if Number_Axes /= Tick_Spacing'length or Number_Axes /= Number_Subticks'length
+ or Number_Axes /= Values'length(1) then
+ Put_Line("*** WARNING: Mismatched array lengths at plcolorbar values");
+ end if;
+
+ -- Adapt Label_Text and Axis_Options to C. See the comment at Create_Stripchart.
+ -- Adapt Label_Text first.
+ for I in Label_Text'range loop
+
+ -- Check length and adjust if necessary.
+ if Length(Label_Text(I)) >= Max_Legend_Label_Length then
+ Put_Line("*** Warning: Colorbar label was truncated to"
+ & Integer'Image(Max_Legend_Label_Length) & " characters. ***");
+ Dum_Text(I) := Head(Label_Text(I), Max_Legend_Label_Length);
+ else
+ Dum_Text(I) := Label_Text(I);
+ end if;
+
+ -- Make the C-style string with null character and spaces immediately after the text.
+ C_Legend_String_Array(I) := To_C(To_String(Dum_Text(I)
+ & Character'val(0)
+ & (Max_Legend_Label_Length - Length(Dum_Text(I))) * " "), False);
+
+ -- Set the I-th pointer in the array of pointers.
+ PL_Label_Text(I) := C_Legend_String_Array(I)'Address;
+ end loop;
+
+ -- Adapt Axis_Options next.
+ for I in Axis_Options'range loop
+
+ -- Check length and adjust if necessary.
+ if Length(Axis_Options(I)) >= Max_Legend_Label_Length then
+ Put_Line("*** Warning: Colorbar asix options label was truncated to"
+ & Integer'Image(Max_Legend_Label_Length) & " characters. ***");
+ Dum_Text(I) := Head(Axis_Options(I), Max_Legend_Label_Length);
+ else
+ Dum_Text(I) := Axis_Options(I);
+ end if;
+
+ -- Make the C-style string with null character and spaces immediately after the text.
+ C_Axis_Options_String_Array(I) := To_C(To_String(Dum_Text(I)
+ & Character'val(0)
+ & (Max_Legend_Label_Length - Length(Dum_Text(I))) * " "), False);
+
+ -- Set the I-th pointer in the array of pointers.
+ PL_Axis_Options(I) := C_Axis_Options_String_Array(I)'Address;
+ end loop;
+
+ -- Adapt values in a similar way as Label_Text: make an array of pointers to Real_Vector.
+ -- We need to transpose because we present the Values matrix to the user as described in the
+ -- PLplot documentation for plcolorbar as rows indexing axes and columns indexing the axis
+ -- values, and Matrix_To_Pointers wants things the other way.
+ PL_Values := Matrix_To_Pointers(PLplot_Thin.PL_Transpose(Values));
+ PLplot_Thin.plcolorbar(Colorbar_Width, Colorbar_Height, Options, Position, X_Offset,
+ Y_Offset, X_Length, Y_Length, Background_Color, Bounding_Box_Color, Bounding_Box_Style,
+ Low_Cap_Color, High_Cap_Color, Contour_Color_For_Shade, Contour_Width_For_Shade,
+ Number_Labels, Label_Options, PL_Label_Text, Number_Axes,
+ PL_Axis_Options, Tick_Spacing, Number_Subticks, Number_Values, PL_Values);
+ end plcolorbar;
+
+
-- Sets position of the light source
procedure pllightsource
(x : Long_Float := 1.0;
@@ -2457,8 +2550,22 @@
begin
PLplot_Thin.plscmap1n(Number_Of_Colors);
end plscmap1n;
-
+
+ -- Set the color map 1 range used in continuous plots.
+ procedure plscmap1_range(Min_Color, Max_Color : Long_Float) is
+ begin
+ PLplot_Thin.plscmap1_range(Min_Color, Max_Color);
+ end plscmap1_range;
+
+
+ -- Get the color map 1 range used in continuous plots
+ procedure plgcmap1_range(Min_Color : out Long_Float; Max_Color : out Long_Float) is
+ begin
+ PLplot_Thin.plgcmap1_range(Min_Color, Max_Color);
+ end plgcmap1_range;
+
+
-- Set a given color from color map 0 by 8 bit RGB value
procedure plscol0
(Plot_Color : Plot_Color_Type;
Modified: trunk/bindings/ada/plplot_traditional.ads
===================================================================
--- trunk/bindings/ada/plplot_traditional.ads 2013-09-24 05:27:13 UTC (rev 12522)
+++ trunk/bindings/ada/plplot_traditional.ads 2013-09-24 10:27:16 UTC (rev 12523)
@@ -2,7 +2,7 @@
-- Ada binding to PLplot using the traditional PLplot subprogram names
--- Copyright (C) 2006-2011 Jerry Bauck
+-- Copyright (C) 2006-2013 Jerry Bauck
-- This file is part of PLplot.
@@ -168,7 +168,7 @@
PL_Position_Viewport : constant Legend_Colorbar_Position_Type := 64;
PL_Position_Subpage : constant Legend_Colorbar_Position_Type := 128;
- --Renamed flags used for position argument of both pllegend and plcolorbar
+ -- Renamed flags used for position argument of both pllegend and plcolorbar
Legend_Position_Left : constant Legend_Colorbar_Position_Type := PL_Position_Left;
Legend_Position_Right : constant Legend_Colorbar_Position_Type := PL_Position_Right;
Legend_Position_Top : constant Legend_Colorbar_Position_Type := PL_Position_Top;
@@ -199,28 +199,42 @@
Legend_Row_Major : constant Legend_Flag_Type := PL_Legend_Row_Major;
-- Flags for plcolorbar (duplicated from plplot_thin.ads)
- PL_Colorbar_Label_Left : constant Colorbar_Flag_Type := 1;
- PL_Colorbar_Label_Right : constant Colorbar_Flag_Type := 2;
- PL_Colorbar_Label_Top : constant Colorbar_Flag_Type := 4;
- PL_Colorbar_Label_Bottom : constant Colorbar_Flag_Type := 8;
- PL_Colorbar_Image : constant Colorbar_Flag_Type := 16;
- PL_Colorbar_Shade : constant Colorbar_Flag_Type := 32;
- PL_Colorbar_Gradient : constant Colorbar_Flag_Type := 64;
- PL_Colorbar_Cap_Low : constant Colorbar_Flag_Type := 128;
- PL_Colorbar_Cap_High : constant Colorbar_Flag_Type := 256;
- PL_Colorbar_Shade_Label : constant Colorbar_Flag_Type := 512;
+ PL_Colorbar_Label_Left : constant Colorbar_Flag_Type := 1;
+ PL_Colorbar_Label_Right : constant Colorbar_Flag_Type := 2;
+ PL_Colorbar_Label_Top : constant Colorbar_Flag_Type := 4;
+ PL_Colorbar_Label_Bottom : constant Colorbar_Flag_Type := 8;
+ PL_Colorbar_Image : constant Colorbar_Flag_Type := 16;
+ PL_Colorbar_Shade : constant Colorbar_Flag_Type := 32;
+ PL_Colorbar_Gradient : constant Colorbar_Flag_Type := 64;
+ PL_Colorbar_Cap_None : constant Colorbar_Flag_Type := 128;
+ PL_Colorbar_Cap_Low : constant Colorbar_Flag_Type := 256;
+ PL_Colorbar_Cap_High : constant Colorbar_Flag_Type := 512;
+ PL_Colorbar_Shade_Label : constant Colorbar_Flag_Type := 1024;
+ PL_Colorbar_Orient_Right : constant Colorbar_Flag_Type := 2048;
+ PL_Colorbar_Orient_Top : constant Colorbar_Flag_Type := 4096;
+ PL_Colorbar_Orient_Left : constant Colorbar_Flag_Type := 8192;
+ PL_Colorbar_Orient_Bottom : constant Colorbar_Flag_Type := 16384;
+ PL_Colorbar_Background : constant Colorbar_Flag_Type := 32768;
+ PL_Colorbar_Bounding_Box : constant Colorbar_Flag_Type := 65536;
-- Renamed flags for plcolorbar
- Colorbar_Label_Left : constant Colorbar_Flag_Type := PL_Colorbar_Label_Left;
- Colorbar_Label_Right : constant Colorbar_Flag_Type := PL_Colorbar_Label_Right;
- Colorbar_Label_Top : constant Colorbar_Flag_Type := PL_Colorbar_Label_Top;
- Colorbar_Label_Bottom : constant Colorbar_Flag_Type := PL_Colorbar_Label_Bottom;
- Colorbar_Image : constant Colorbar_Flag_Type := PL_Colorbar_Image;
- Colorbar_Shade : constant Colorbar_Flag_Type := PL_Colorbar_Shade;
- Colorbar_Gradient : constant Colorbar_Flag_Type := PL_Colorbar_Gradient;
- Colorbar_Cap_Low : constant Colorbar_Flag_Type := PL_Colorbar_Cap_Low;
- Colorbar_Cap_High : constant Colorbar_Flag_Type := PL_Colorbar_Cap_High;
- Colorbar_Shade_Label : constant Colorbar_Flag_Type := PL_Colorbar_Shade_Label;
+ Colorbar_Label_Left : constant Colorbar_Flag_Type := PL_Colorbar_Label_Left;
+ Colorbar_Label_Right : constant Colorbar_Flag_Type := PL_Colorbar_Label_Right;
+ Colorbar_Label_Top : constant Colorbar_Flag_Type := PL_Colorbar_Label_Top;
+ Colorbar_Label_Bottom : constant Colorbar_Flag_Type := PL_Colorbar_Label_Bottom;
+ Colorbar_Image : constant Colorbar_Flag_Type := PL_Colorbar_Image;
+ Colorbar_Shade : constant Colorbar_Flag_Type := PL_Colorbar_Shade;
+ Colorbar_Gradient : constant Colorbar_Flag_Type := PL_Colorbar_Gradient;
+ Colorbar_Cap_None : constant Colorbar_Flag_Type := PL_Colorbar_Cap_None;
+ Colorbar_Cap_Low : constant Colorbar_Flag_Type := PL_Colorbar_Cap_Low;
+ Colorbar_Cap_High : constant Colorbar_Flag_Type := PL_Colorbar_Cap_High;
+ Colorbar_Shade_Label : constant Colorbar_Flag_Type := PL_Colorbar_Shade_Label;
+ Colorbar_Orient_Right : constant Colorbar_Flag_Type := PL_Colorbar_Orient_Right;
+ Colorbar_Orient_Top : constant Colorbar_Flag_Type := PL_Colorbar_Orient_Top;
+ Colorbar_Orient_Left : constant Colorbar_Flag_Type := PL_Colorbar_Orient_Left;
+ Colorbar_Orient_Bottom : constant Colorbar_Flag_Type := PL_Colorbar_Orient_Bottom;
+ Colorbar_Background : constant Colorbar_Flag_Type := PL_Colorbar_Background;
+ Colorbar_Bounding_Box : constant Colorbar_Flag_Type := PL_Colorbar_Bounding_Box;
-- Justification for plots
subtype Justification_Type is Integer range -1..2;
@@ -1225,7 +1239,7 @@
X_Offset, Y_Offset : Long_Float;
Plot_Area_Width : Long_Float;
Background_Color, Bounding_Box_Color : Plot_Color_Type;
- Bounding_Box_Style : Legend_Flag_Type;
+ Bounding_Box_Style : Line_Style_Type;
Number_Rows, Number_Columns : Integer;
Entry_Options : Integer_Array_1D;
Text_Offset, Text_Scale, Text_Spacing : Long_Float;
@@ -1243,6 +1257,26 @@
Symbols : Legend_String_Array_Type);
+ -- Routine for drawing continous colour legends
+ procedure plcolorbar
+ (Colorbar_Width, Colorbar_Height : out Long_Float;
+ Options, Position : Integer;
+ X_Offset, Y_Offset : Long_Float;
+ X_Length, Y_Length : Long_Float;
+ Background_Color, Bounding_Box_Color : Plot_Color_Type;
+ Bounding_Box_Style : Line_Style_Type;
+ Low_Cap_Color, High_Cap_Color : Long_Float;
+ Contour_Color_For_Shade : Plot_Color_Type;
+ Contour_Width_For_Shade : Long_Float;
+ Label_Options : Integer_Array_1D;
+ Label_Text : Legend_String_Array_Type;
+ Axis_Options : Legend_String_Array_Type;
+ Tick_Spacing : Real_Vector;
+ Number_Subticks : Integer_Array_1D;
+ Number_Values : Integer_Array_1D;
+ Values : Real_Matrix);
+
+
-- Sets position of the light source
procedure pllightsource
(x : Long_Float := 1.0;
@@ -1527,6 +1561,14 @@
procedure plscmap1n(Number_Of_Colors : Integer);
+ -- Set the color map 1 range used in continuous plots.
+ procedure plscmap1_range(Min_Color, Max_Color : Long_Float);
+
+
+ -- Get the color map 1 range used in continuous plots
+ procedure plgcmap1_range(Min_Color, Max_Color : out Long_Float);
+
+
-- Set a given color from color map 0 by 8 bit RGB value
procedure plscol0
(Plot_Color : Plot_Color_Type;
Modified: trunk/examples/ada/x16a.adb
===================================================================
--- trunk/examples/ada/x16a.adb 2013-09-24 05:27:13 UTC (rev 12522)
+++ trunk/examples/ada/x16a.adb 2013-09-24 10:27:16 UTC (rev 12523)
@@ -6,7 +6,7 @@
-- IFS, University of Texas at Austin
-- 20 Mar 1994
--- Copyright (C) 2008 Jerry Bauck
+-- Copyright (C) 2008-2013 Jerry Bauck
-- This file is part of PLplot.
@@ -36,8 +36,6 @@
PLplot_Traditional,
PLplot_Auxiliary;
-
-
procedure x16a is
-- Fundamental settings. See notes() for more info.
ns : Integer := 20; -- Default number of shade levels
@@ -65,8 +63,20 @@
y_Last => ny - 1);
fill_width : Long_Float := 2.0;
+ colorbar_width, colorbar_height : Long_Float;
cont_color : Integer := 0;
cont_width : Long_Float := 0.0;
+ num_axes : constant Integer := 1;
+ n_axis_opts : constant Integer := num_axes;
+ -- TUB is renamed To_Unbounded_String.
+ axis_opts : Legend_String_Array_Type(0 .. n_axis_opts - 1) := (others => TUB("bcvtm"));
+ num_values : Integer_Array_1D(0 .. num_axes - 1);
+ values : Real_Matrix(0 .. num_axes - 1, 0 .. ns);
+ axis_ticks : Real_Vector(0 .. num_axes - 1) := (others => 0.0);
+ axis_subticks : Integer_Array_1D(0 .. num_axes - 1) := (others => 0);
+ num_labels : constant Integer := 1;
+ label_opts : Integer_Array_1D(0 .. num_labels - 1);
+ labels : Legend_String_Array_Type(0 .. num_labels - 1) := (others => TUB("Magnitude"));
-- Transformation function
tr : Real_Vector(0 .. 5);
@@ -77,6 +87,7 @@
pltr_data : PLpointer);
pragma Convention(Convention => C, Entity => mypltr);
+
procedure mypltr
(x, y : Long_Float;
tx, ty : out Long_Float;
@@ -101,14 +112,15 @@
end if;
end zdefined;
+begin
+ label_opts(0) := COLORBAR_LABEL_BOTTOM;
-begin
----------------------------------------------------------------------------
-- Does several shade plots using different coordinate mappings.
----------------------------------------------------------------------------
-- Parse and process command line arguments.
- plparseopts(PL_PARSE_FULL);
+ plparseopts(Parse_Full);
-- Load colour palettes
plspal0("cmap0_black_on_white.pal");
@@ -178,6 +190,30 @@
cont_color, cont_width,
plfill'access, True, Null, System.Null_Address);
+ -- Smaller text
+ plschr(0.0, 0.75);
+ -- Small ticks on the vertical axis
+ plsmaj(0.0, 0.5);
+ plsmin(0.0, 0.5);
+
+ num_values(0) := ns + 1;
+ for i in values'range(2) loop
+ values(0, i) := shedge(i);
+ end loop;
+ plcolorbar(colorbar_width, colorbar_height,
+ Colorbar_Shade + Colorbar_Shade_Label, 0,
+ 0.005, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0,
+ cont_color, cont_width,
+ label_opts, labels,
+ axis_opts,
+ axis_ticks, axis_subticks,
+ num_values, values);
+
+ -- Reset text and tick sizes
+ plschr(0.0, 1.0);
+ plsmaj(0.0, 1.0);
+ plsmin(0.0, 1.0);
+
plcol0(1);
plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
plcol0(2);
@@ -204,6 +240,30 @@
cont_color, cont_width,
plfill'access, True, pltr1'access, cgrid1'Address);
+ -- Smaller text
+ plschr(0.0, 0.75);
+ -- Small ticks on the vertical axis
+ plsmaj(0.0, 0.5);
+ plsmin(0.0, 0.5);
+
+ num_values(0) := ns + 1;
+ for i in values'range(2) loop
+ values(0, i) := shedge(i);
+ end loop;
+ plcolorbar(colorbar_width, colorbar_height,
+ Colorbar_Shade + Colorbar_Shade_Label, 0,
+ 0.005, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0,
+ cont_color, cont_width,
+ label_opts, labels,
+ axis_opts,
+ axis_ticks, axis_subticks,
+ num_values, values);
+
+ -- Reset text and tick sizes
+ plschr(0.0, 1.0);
+ plsmaj(0.0, 1.0);
+ plsmin(0.0, 1.0);
+
plcol0(1);
plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
plcol0(2);
@@ -230,6 +290,30 @@
cont_color, cont_width,
plfill'access, False, pltr2'access, cgrid2'Address);
+ -- Smaller text
+ plschr(0.0, 0.75);
+ -- Small ticks on the vertical axis
+ plsmaj(0.0, 0.5);
+ plsmin(0.0, 0.5);
+
+ num_values(0) := ns + 1;
+ for i in values'range(2) loop
+ values(0, i) := shedge(i);
+ end loop;
+ plcolorbar(colorbar_width, colorbar_height,
+ Colorbar_Shade + Colorbar_Shade_Label, 0,
+ 0.005, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0,
+ cont_color, cont_width,
+ label_opts, labels,
+ axis_opts,
+ axis_ticks, axis_subticks,
+ num_values, values);
+
+ -- Reset text and tick sizes
+ plschr(0.0, 1.0);
+ plsmaj(0.0, 1.0);
+ plsmin(0.0, 1.0);
+
plcol0(1);
plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
plcol0(2);
@@ -257,6 +341,30 @@
2, 3.0,
plfill'access, False, pltr2'access, cgrid2'Address);
+ -- Smaller text
+ plschr(0.0, 0.75);
+ -- Small ticks on the vertical axis
+ plsmaj(0.0, 0.5);
+ plsmin(0.0, 0.5);
+
+ num_values(0) := ns + 1;
+ for i in values'range(2) loop
+ values(0, i) := shedge(i);
+ end loop;
+ plcolorbar(colorbar_width, colorbar_height,
+ Colorbar_Shade + Colorbar_Shade_Label, 0,
+ 0.005, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0,
+ 2, 3.0,
+ label_opts, labels,
+ axis_opts,
+ axis_ticks, axis_subticks,
+ num_values, values);
+
+ -- Reset text and tick sizes
+ plschr(0.0, 1.0);
+ plsmaj(0.0, 1.0);
+ plsmin(0.0, 1.0);
+
plcol0(1);
plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
plcol0(2);
@@ -270,7 +378,7 @@
-- Ada note: This "exclusion" part works if exclude is set to True.
-- In the C original example, the setting of exclude was handled by the
-- the input parser which handling is not implemented in this Ada example.
--- exclude := False;
+ -- exclude := False;
if exclude then
-- Load colour palettes.
@@ -337,6 +445,30 @@
cont_color, cont_width,
plfill'access, False, pltr2'access, cgrid2'Address);
+ -- Smaller text
+ plschr(0.0, 0.75);
+ -- Small ticks on the vertical axis
+ plsmaj(0.0, 0.5);
+ plsmin(0.0, 0.5);
+
+ num_values(0) := ns + 1;
+ for i in values'range(2) loop
+ values(0, i) := shedge(i);
+ end loop;
+ plcolorbar(colorbar_width, colorbar_height,
+ Colorbar_Shade + Colorbar_Shade_Label, 0,
+ 0.005, 0.0, 0.0375, 0.875, 0, 1, 1, 0.0, 0.0,
+ cont_color, cont_width,
+ label_opts, labels,
+ axis_opts,
+ axis_ticks, axis_subticks,
+ num_values, values);
+
+ -- Reset text and tick sizes
+ plschr(0.0, 1.0);
+ plsmaj(0.0, 1.0);
+ plsmin(0.0, 1.0);
+
-- Now we can draw the perimeter. (If do before, shade stuff may overlap.)
for i in px'range loop
t := 2.0 * pi / Long_Float(px'Length - 1) * Long_Float(i);
Modified: trunk/examples/ada/x33a.adb
===================================================================
--- trunk/examples/ada/x33a.adb 2013-09-24 05:27:13 UTC (rev 12522)
+++ trunk/examples/ada/x33a.adb 2013-09-24 10:27:16 UTC (rev 12523)
@@ -4,7 +4,7 @@
--
-- Demonstrate most pllegend capability including unicode symbols.
--
--- Copyright (C) 2011 Jerry Bauck
+-- Copyright (C) 2011-2013 Jerry Bauck
--
-- This file is part of PLplot.
--
@@ -46,224 +46,221 @@
PLplot_Auxiliary,
PLplot_Traditional;
+----------------------------------------------------------------------------
+-- Demonstrate most pllegend capability including unicode symbols.
+----------------------------------------------------------------------------
+
procedure x33a is
position_options : Integer_Array_1D(0 .. 15) :=
- (PL_POSITION_LEFT + PL_POSITION_TOP + PL_POSITION_OUTSIDE,
- PL_POSITION_TOP + PL_POSITION_OUTSIDE,
- PL_POSITION_RIGHT + PL_POSITION_TOP + PL_POSITION_OUTSIDE,
- PL_POSITION_RIGHT + PL_POSITION_OUTSIDE,
- PL_POSITION_RIGHT + PL_POSITION_BOTTOM + PL_POSITION_OUTSIDE,
- PL_POSITION_BOTTOM + PL_POSITION_OUTSIDE,
- PL_POSITION_LEFT + PL_POSITION_BOTTOM + PL_POSITION_OUTSIDE,
- PL_POSITION_LEFT + PL_POSITION_OUTSIDE,
- PL_POSITION_LEFT + PL_POSITION_TOP + PL_POSITION_INSIDE,
- PL_POSITION_TOP + PL_POSITION_INSIDE,
- PL_POSITION_RIGHT + PL_POSITION_TOP + PL_POSITION_INSIDE,
- PL_POSITION_RIGHT + PL_POSITION_INSIDE,
- PL_POSITION_RIGHT + PL_POSITION_BOTTOM + PL_POSITION_INSIDE,
- PL_POSITION_BOTTOM + PL_POSITION_INSIDE,
- PL_POSITION_LEFT + PL_POSITION_BOTTOM + PL_POSITION_INSIDE,
- PL_POSITION_LEFT + PL_POSITION_INSIDE);
+ (Pl_Position_Left + Pl_Position_Top + Pl_Position_Outside,
+ Pl_Position_Top + Pl_Position_Outside,
+ Pl_Position_Right + Pl_Position_Top + Pl_Position_Outside,
+ Pl_Position_Right + Pl_Position_Outside,
+ Pl_Position_Right + Pl_Position_Bottom + Pl_Position_Outside,
+ Pl_Position_Bottom + Pl_Position_Outside,
+ Pl_Position_Left + Pl_Position_Bottom + Pl_Position_Outside,
+ Pl_Position_Left + Pl_Position_Outside,
+ Pl_Position_Left + Pl_Position_Top + Pl_Position_Inside,
+ Pl_Position_Top + Pl_Position_Inside,
+ Pl_Position_Right + Pl_Position_Top + Pl_Position_Inside,
+ Pl_Position_Right + Pl_Position_Inside,
+ Pl_Position_Right + Pl_Position_Bottom + Pl_Position_Inside,
+ Pl_Position_Bottom + Pl_Position_Inside,
+ Pl_Position_Left + Pl_Position_Bottom + Pl_Position_Inside,
+ Pl_Position_Left + Pl_Position_Inside);
-- Pick 5 arbitrary UTF-8 symbols useful for plotting points (✠✚✱✪✽✺✰✴✦).
special_symbols : Legend_String_Array_Type(0 .. 4) :=
- (TUB("✰"), TUB("✴"), TUB("✱"), TUB("✽"), TUB("✦"));
+ (TUB("✰"), TUB("✴"), TUB("✱"), TUB("✽"), TUB("✦")); -- TUB is renamed To_Unbounded_String.
- colorbar : Boolean := False; -- By default do not plot plcolorbar pages
- -- for now while we are working out the API.
+ -- plcolorbar options
--- static PLOptionTable options() := {
--- {
--- "colorbar", -- Turns on pages showing colorbars
--- NULL,
--- NULL,
--- &colorbar,
--- PL_OPT_BOOL,
--- "-colorbar",
--- "Plot the \"color bar\" pages."
--- },
--- {
--- NULL, -- option
--- NULL, -- handler
--- NULL, -- client data
--- NULL, -- address of variable to set
--- 0, -- mode flag
--- NULL, -- short syntax
--- NULL
--- } -- long syntax
--- };
+ -- Colorbar type options
+ Colorbar_Kinds : constant Integer := 4;
+ colorbar_option_kinds : Integer_Array_1D(0 .. Colorbar_Kinds - 1) := (
+ Pl_Colorbar_Shade,
+ Pl_Colorbar_Shade + Pl_Colorbar_Shade_Label,
+ Pl_Colorbar_Image,
+ Pl_Colorbar_Gradient);
+ colorbar_option_kind_labels : Legend_String_Array_Type(0 .. Colorbar_Kinds - 1) :=
+ (TUB("Shade colorbars"),
+ TUB("Shade colorbars with custom labels"),
+ TUB("Image colorbars"),
+ TUB("Gradient colorbars"));
---const char *notes() := { "Make sure you get it right!", NULL };
+ -- Which side of the page are we positioned relative to?
+ Colorbar_Positions :constant Integer := 4;
+ colorbar_position_options : Integer_Array_1D(0 .. Colorbar_Positions - 1) :=
+ (Pl_Position_Left,
+ Pl_Position_Right,
+ Pl_Position_Top,
+ Pl_Position_Bottom);
+
+ colorbar_position_option_labels : Legend_String_Array_Type(0 .. Colorbar_Positions - 1) :=
+ (TUB("Left"),
+ TUB("Right"),
+ TUB("Top"),
+ TUB("Bottom"));
+
+ -- Colorbar label positioning options
+ Colorbar_Labels : constant Integer := 4;
+ colorbar_label_options : Integer_Array_1D(0 .. Colorbar_Labels - 1) :=
+ (Pl_Colorbar_Label_Left,
+ Pl_Colorbar_Label_Right,
+ Pl_Colorbar_Label_Top,
+ Pl_Colorbar_Label_Bottom);
- --procedure plcolorbar_example_1(PLINT bar_type, PLINT cont_color, PLINT cont_width, PLFLT ticks, PLINT sub_ticks, PLINT n, PLFLT *values, const char *title)
+ colorbar_label_option_labels : Legend_String_Array_Type(0 .. Colorbar_Labels - 1) :=
+ (TUB("Label left"),
+ TUB("Label right"),
+ TUB("Label top"),
+ TUB("Label bottom"));
+
+ -- Colorbar cap options
+ Colorbar_Caps : constant Integer := 4;
+ colorbar_cap_options : Integer_Array_1D(0 .. Colorbar_Caps - 1) :=
+ (Pl_Colorbar_Cap_None,
+ Pl_Colorbar_Cap_Low,
+ Pl_Colorbar_Cap_High,
+ Pl_Colorbar_Cap_Low + Pl_Colorbar_Cap_High);
+ colorbar_cap_option_labels : Legend_String_Array_Type(0 .. Colorbar_Caps - 1) :=
+ (TUB("No caps"),
+ TUB("Low cap"),
+ TUB("High cap"),
+ TUB("Low and high caps"));
- -- procedure plcolorbar_example_1
- -- (bar_type, cont_color, cont_width : Integer;
- -- ticks : Long_Float;
- -- sub_ticks, n : Integer;
- -- values : Real_Vector;
- -- title : Unbounded_String)
- -- is
- -- colors : Real_Vector(0 .. n - 1);
- -- i : Integer;
- -- color_step, color_offset : Long_Float;
- -- opt, position : Integer;
- -- axis_opts_1, axis_opts_2 : Unbounded_String;
- -- begin
- -- pladv(0);
- --
- -- -- Set up color palette 1.
- -- plspal1("cmap1_blue_red.pal", True);
- --
- -- color_step := 1.0 / Long_Float(n - 1);
- -- for i in 0 .. n - 1 loop
- -- colors(i) := color_offset + color_step * Long_Float(i); -- COLOR_OFFSET NOT DEFINED!
- -- end loop;
- --
- -- position := PL_POSITION_LEFT;
- -- opt := bar_type + PL_COLORBAR_LABEL_LEFT + PL_COLORBAR_CAP_HIGH;
- --
- -- if bar_type and PL_COLORBAR_SHADE_LABEL then
- -- axis_opts_1 := To_Unbounded_String("iv");
- -- axis_opts_2 := To_Unbounded_String("i");
- -- else
- -- if sub_ticks /= 0 then
- -- axis_opts_1 := To_Unbounded_String("stv");
- -- axis_opts_2 := To_Unbounded_String("st");
- -- else
- -- axis_opts_1 := To_Unbounded_String("tv");
- -- axis_opts_2 := To_Unbounded_String("t");
- -- end if;
- -- end if;
- --
- -- plcolorbar(opt, position, 0.1, 0.1, 0.5, 0.1, -- fixme
- -- cont_color, cont_width,
- -- ticks, sub_ticks,
- -- axis_opts_1, "Test label - Left, High Cap",
- -- n, colors, values);
- --
- -- position := PL_POSITION_RIGHT;
- -- opt := bar_type + PL_COLORBAR_LABEL_RIGHT + PL_COLORBAR_CAP_LOW;
- --
- -- plcolorbar(opt, position, 0.1, 0.4, 0.5, 0.1, -- fixme etc.
- -- cont_color, cont_width,
- -- ticks, sub_ticks,
- -- axis_opts_1, "Test label - Right, Low Cap",
- -- n, colors, values);
- --
- -- position := PL_POSITION_TOP;
- -- opt := bar_type + PL_COLORBAR_LABEL_TOP + PL_COLORBAR_CAP_HIGH;
- --
- -- plcolorbar(opt, position, 0.1, 0.1, 0.5, 0.1,
- -- cont_color, cont_width,
- -- ticks, sub_ticks,
- -- axis_opts_2, "Test label - Top, High Cap",
- -- n, colors, values);
- --
- -- position := PL_POSITION_BOTTOM;
- -- opt := bar_type + PL_COLORBAR_LABEL_BOTTOM + PL_COLORBAR_CAP_LOW;
- --
- -- plcolorbar(opt, position, 0.4, 0.1, 0.5, 0.1,
- -- cont_color, cont_width,
- -- ticks, sub_ticks,
- -- axis_opts_2, "Test label - Bottom, Low Cap",
- -- n, colors, values);
- --
- -- plvpor(0.0, 1.0, 0.0, 1.0);
- -- plwind(0.0, 1.0, 0.0, 1.0);
- -- plptex(0.5, 0.5, 0.0, 0.0, 0.5, To_String(title));
- -- end plcolorbar_example_1;
- --
- --
- -- procedure plcolorbar_example_2
- -- (bar_type, cont_color, cont_width : Integer;
- -- ticks, sub_ticks : Long_Float;
- -- n : Integer;
- -- values : Real_Vector;
- -- title : Unbounded_String)
- -- is
- -- colors : Long_Float(0 .. n - 1);
- -- i : Integer;
- -- color_step, color_offset : Long_Float;
- -- opt, position : Integer;
- -- axis_opts_1, axis_opts_2 : Unbounded_String;
- -- begin
- -- pladv(0);
- --
- -- -- Set up color palette 1.
- -- plspal1("cmap1_blue_yellow.pal", True);
- --
- -- color_step := 1.0 / Long_Float(n - 1);
- -- for i in 0 .. n - 1 loop
- -- if i = 0 then
- -- color_offset := 0.01;
- -- elsif i = n - 1 then
- -- color_offset := -0.01;
- -- else
- -- color_offset := 0.0;
- -- end if;
- -- colors(i) := color_offset + color_step * Long_Float(i);
- -- end loop;
- --
- -- position := PL_POSITION_LEFT;
- -- opt := bar_type + PL_COLORBAR_LABEL_LEFT + PL_COLORBAR_CAP_LOW;
- --
- -- if bar_type = PL_COLORBAR_SHADE_LABEL then
- -- axis_opts_1 := "";
- -- axis_opts_2 := "";
- -- else
- -- if sub_ticks /= 0 then
- -- axis_opts_1 := "stv";
- -- axis_opts_2 := "st";
- -- else
- -- axis_opts_1 := "tv";
- -- axis_opts_2 := "t";
- -- end if;
- -- end if;
- --
- -- plcolorbar(opt, position, 0.1, 0.1, 0.5, 0.1,
- -- cont_color, cont_width,
- -- ticks, sub_ticks,
- -- axis_opts_1, "Test label - Left, Low Cap",
- -- n, colors, values);
- --
- -- position := PL_POSITION_RIGHT;
- -- opt := bar_type + PL_COLORBAR_LABEL_RIGHT + PL_COLORBAR_CAP_HIGH;
- --
- -- plcolorbar(opt, position, 0.1, 0.4, 0.5, 0.1,
- -- cont_color, cont_width,
- -- ticks, sub_ticks,
- -- axis_opts_1, "Test label - Right, High Cap",
- -- n, colors, values);
- --
- -- position := PL_POSITION_TOP;
- -- opt := bar_type + PL_COLORBAR_LABEL_TOP + PL_COLORBAR_CAP_LOW;
- --
- -- plcolorbar(opt, position, 0.1, 0.1, 0.5, 0.1,
- -- cont_color, cont_width,
- -- ticks, sub_ticks,
- -- axis_opts_2, "Test label - Top, Low Cap",
- -- n, colors, values);
- --
- -- position := PL_POSITION_BOTTOM;
- -- opt := bar_type + PL_COLORBAR_LABEL_BOTTOM + PL_COLORBAR_CAP_HIGH;
- --
- -- plcolorbar(opt, position, 0.4, 0.1, 0.5, 0.1,
- -- cont_color, cont_width,
- -- ticks, sub_ticks,
- -- axis_opts_2, "Test label - Bottom, High Cap",
- -- n, colors, values);
- --
- -- plvpor(0.0, 1.0, 0.0, 1.0);
- -- plwind(0.0, 1.0, 0.0, 1.0);
- -- plptex(0.5, 0.5, 0.0, 0.0, 0.5, To_String(title));
- -- end plcolorbar_example_2;
+ procedure plcolorbar_example_page(kind_i : Integer; label_i : Integer; cap_i : Integer;
+ cont_color : Integer; cont_width : Long_Float; n_values : Integer; values : Real_Vector)
+ is
+ -- Parameters for the colorbars on this page
+ position, opt : Integer;
+ x, y, x_length, y_length : Long_Float;
+ ticks : Real_Vector(0 .. 0) := (others => 0.0);
+ sub_ticks : Integer_Array_1D(0 .. 0) := (others => 0);
+ low_cap_color, high_cap_color : Long_Float;
+ vertical, ifn : Boolean;
+ n_axes : Integer := 1;
+ axis_opts : Legend_String_Array_Type(0 .. 0);
+ n_labels : Integer := 1;
+ label_opts : Integer_Array_1D(0 .. 0) := (others => 0);
+ label : Legend_String_Array_Type(0 .. 0);
+ title : Unbounded_String;
+ colorbar_width, colorbar_height : Long_Float;
+ n_values_array : Integer_Array_1D(0 .. 0);
+ values_array : Real_Matrix(0 .. 0, values'first .. values'last);
+ type Stupid is mod 2**7; -- To cover Legend_Colorbar_Position_Type in plplot_thin.ads.
+ begin
+ n_values_array(0) := n_values;
+ for i in values'range loop
+ values_array(0, i) := values(i);
+ end loop;
-----------------------------------------------------------------------------
--- Demonstrate most pllegend capability including unicode symbols.
-----------------------------------------------------------------------------
+ low_cap_color := 0.0;
+ high_cap_color := 1.0;
+ -- Start a new page.
+ pladv(0);
+
+ -- Draw one colorbar relative to each side of the page.
+ for position_i in 0 .. Colorbar_Positions - 1 loop
+ position := colorbar_position_options(position_i);
+ opt := colorbar_option_kinds(kind_i) +
+ colorbar_label_options(label_i) + colorbar_cap_options(cap_i);
+
+ -- We have to convert these integers to modular type Stupid before and-ing the bits.
+ -- That's because manipulating bits of non-modular types is nonsense but other
+ -- languages seem to not care about stuff like this.
+ vertical := ((Stupid(position) and Stupid(Pl_Position_Left)) > 0) or
+ ((Stupid(position) and Stupid(Pl_Position_Right)) > 0);
+
+ ifn := ((Stupid(position) and Stupid(Pl_Position_Left)) > 0) or
+ ((Stupid(position) and Stupid(Pl_Position_Bottom)) > 0);
+
+ -- Set the offset position on the page.
+ if vertical then
+ x := 0.0;
+ y := 0.0;
+ x_length := 0.05;
+ y_length := 0.5;
+ else
+ x := 0.0;
+ y := 0.0;
+ x_length := 0.5;
+ y_length := 0.05;
+ end if;
+
+ -- Set appropriate labelling options.
+ if ifn then
+ if cont_color = 0 or cont_width = 0.0 then
+ axis_opts(0) := TUB("uwtivn"); -- TUB is renamed To_Unbounded_String.
+ else
+ axis_opts(0) := TUB("uwxvn");
+ end if;
+ else
+ if cont_color = 0 or cont_width = 0.0 then
+ axis_opts(0) := TUB("uwtivm");
+ else
+ axis_opts(0) := TUB("uwxvm");
+ end if;
+ end if;
+
+ label(0) := colorbar_position_option_labels(position_i) & ", "
+ & colorbar_label_option_labels(label_i);
+
+ -- Smaller text
+ plschr(0.0, 0.75);
+ -- Small ticks on the vertical axis
+ plsmaj(0.0, 0.5);
+ plsmin...
[truncated message content] |