1----------------------------------------------------------------------- 2-- GtkAda - Ada95 binding for Gtk+/Gnome -- 3-- -- 4-- Copyright (C) 2000 E. Briot, J. Brobecker and A. Charlet -- 5-- Copyright (C) 2000-2013, AdaCore -- 6-- -- 7-- This library is free software; you can redistribute it and/or -- 8-- modify it under the terms of the GNU General Public -- 9-- License as published by the Free Software Foundation; either -- 10-- version 2 of the License, or (at your option) any later version. -- 11-- -- 12-- This library is distributed in the hope that it will be useful, -- 13-- but WITHOUT ANY WARRANTY; without even the implied warranty of -- 14-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- 15-- General Public License for more details. -- 16-- -- 17-- You should have received a copy of the GNU General Public -- 18-- License along with this library; if not, write to the -- 19-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- 20-- Boston, MA 02111-1307, USA. -- 21-- -- 22-- As a special exception, if other files instantiate generics from -- 23-- this unit, or you link this unit with other files to produce an -- 24-- executable, this unit does not by itself cause the resulting -- 25-- executable to be covered by the GNU General Public License. This -- 26-- exception does not however invalidate any other reasons why the -- 27-- executable file might be covered by the GNU Public License. -- 28----------------------------------------------------------------------- 29 30-- <description> 31-- 32-- This package implements a high-level, general purpose plotting widget. 33-- You can display any set of data (set of points, curve defined by a 34-- parametric function, ...). This widget can automatically display them 35-- as a curve, along with labelled axis, axis tic marks, legends,... 36-- 37-- This is the base class, that provides 2D graphics. Some children provide 38-- polar-coordinates and 3D graphics in addition. 39-- 40-- It fully supports the drag-and-drop protocol for all of its children, 41-- which means that the user can interactively move them in the Gtk_Plot 42-- area. 43-- 44-- A Gtk_Plot is closely associated with a Gdk_Drawable, on which all the 45-- drawings are done. It can be done anywhere within that drawable, its 46-- "position" is indicated by a tuple (X, Y), which are two values between 47-- 0.0 and 1.0 (from left to right, or from top to bottom). 48-- Its size is also given as a ratio other the drawable's size. 49-- 50-- Most points in the plot have also this relative coordinates systems, which 51-- makes it really easy to handle resizing of a plot window. 52-- 53-- See the package Gtk.Extra.Plot_Ps for a way to easily print a Gtk_Plot to 54-- a postscript file. 55-- 56-- In this package, font parameters are sometimes required. Here is the 57-- list of possible fonts used by Gtk.Extra: 58-- 59-- - "Times-Roman", 60-- - "Times-Italic", 61-- - "Times-Bold", 62-- - "Times-BoldItalic", 63-- - "AvantGarde-Book", 64-- - "AvantGarde-BookOblique", 65-- - "AvantGarde-Demi", 66-- - "AvantGarde-DemiOblique", 67-- - "Bookman-Light", 68-- - "Bookman-LightItalic", 69-- - "Bookman-Demi", 70-- - "Bookman-DemiItalic", 71-- - "Courier", 72-- - "Courier-Oblique", 73-- - "Courier-Bold", 74-- - "Courier-BoldOblique", 75-- - "Helvetica", 76-- - "Helvetica-Oblique", 77-- - "Helvetica-Bold", 78-- - "Helvetica-BoldOblique", 79-- - "Helvetica-Narrow", 80-- - "Helvetica-Narrow-Oblique", 81-- - "Helvetica-Narrow-Bold", 82-- - "Helvetica-Narrow-BoldOblique", 83-- - "NewCenturySchoolbook-Roman", 84-- - "NewCenturySchoolbook-Italic", 85-- - "NewCenturySchoolbook-Bold", 86-- - "NewCenturySchoolbook-BoldItalic", 87-- - "Palatino-Roman", 88-- - "Palatino-Italic", 89-- - "Palatino-Bold", 90-- - "Palatino-BoldItalic", 91-- - "Symbol", 92-- - "ZapfChancery-MediumItalic", 93-- - "ZapfDingbats", 94-- 95-- </description> 96-- <c_version>gtkextra 2.1.1</c_version> 97-- <group>Plotting Data</group> 98-- <testgtk>create_plot.adb</testgtk> 99-- <screenshot>gtk-plot</screenshot> 100 101with Glib.Object; 102 103with System; 104with Gdk.Color; 105with Gdk.Drawable; 106with Gdk.Pixmap; 107with Gdk.Rectangle; 108with Gtk.Enums; 109with Gtk.Extra.Plot_Data; use Gtk.Extra.Plot_Data; 110with Gtk.Widget; 111 112package Gtk.Extra.Plot is 113 114 type Gtk_Plot_Record is new Gtk.Widget.Gtk_Widget_Record with private; 115 type Gtk_Plot is access all Gtk_Plot_Record'Class; 116 117 type Gtk_Plot_Axis_Record is new Glib.Object.GObject_Record with private; 118 type Gtk_Plot_Axis is access all Gtk_Plot_Axis_Record'Class; 119 -- One of the axis of the plot. 120 -- There are up to six axis for each plot, one on each side. They can have 121 -- ticks, labels, etc. 122 123 type Gtk_Plot_Text is new Gdk.C_Proxy; 124 -- A text that can be displayed anywhere on the plot. 125 126 type Gtk_Plot_Line is new Gdk.C_Proxy; 127 -- A simple line drawn on the plot. 128 129 type Gtk_Plot_Symbol is new Gdk.C_Proxy; 130 type Gtk_Plot_Tick is new Gdk.C_Proxy; 131 type Gtk_Plot_Ticks is new Gdk.C_Proxy; 132 133 type Plot_Vector is record 134 X, Y, Z : Gdouble; 135 end record; 136 137 ---------------- 138 -- Enum types -- 139 ---------------- 140 141 type Plot_Border_Style is 142 (Border_None, 143 -- No border is drawn 144 145 Border_Line, 146 -- A simple line on each side 147 148 Border_Shadow 149 -- The right and bottom lines are 150 -- thicker 151 ); 152 -- Border types used for legends. 153 pragma Convention (C, Plot_Border_Style); 154 155 -- subtype Plot_Scale is Gtk.Extra.Plot_Data.Plot_Scale; 156 -- subtype Plot_Label_Style is Gtk.Extra.Plot_Data.Plot_Label_Style; 157 -- subtype Plot_Symbol_Style is Gtk.Extra.Plot_Data.Plot_Symbol_Style; 158 -- subtype Plot_Symbol_Type is Gtk.Extra.Plot_Data.Plot_Symbol_Type; 159 -- subtype Plot_Line_Style is Gtk.Extra.Plot_Data.Plot_Line_Style; 160 -- subtype Plot_Connector is Gtk.Extra.Plot_Data.Plot_Connector; 161 162 -- In C, these types are declared in gtkplot.h. However, because of type 163 -- circularity, we need to define them in Gtk.Extra.Plot_Data, and have 164 -- subtypes here. This would lead to unnecessary required qualification in 165 -- user code though... 166 167 type Plot_Label_Pos is new Integer; 168 -- Position of labels along an axis. 169 170 Label_None : constant Plot_Label_Pos; 171 Label_In : constant Plot_Label_Pos; 172 Label_Out : constant Plot_Label_Pos; 173 174 type Plot_Error is (Error_Div_Zero, Error_Log_Neg); 175 -- Errors that can be encountered while calculating a graph. 176 pragma Convention (C, Plot_Error); 177 178 type Plot_Axis_Pos is (Axis_Left, Axis_Right, Axis_Top, Axis_Bottom); 179 -- Where the axis should be put 180 pragma Convention (C, Plot_Axis_Pos); 181 182 type Plot_Orientation is (Axis_X, Axis_Y, Axis_Z); 183 -- How to reference axis in 3D plots 184 pragma Convention (C, Plot_Orientation); 185 186 type Plot_Ticks_Pos is new Integer; 187 -- The position and orientation of the ticks along an axis. 188 -- See the constants below for the possible values. 189 -- Note also that not all the values are valid with all types of axis. 190 191 Ticks_None : constant Plot_Ticks_Pos; 192 Ticks_In : constant Plot_Ticks_Pos; 193 Ticks_Out : constant Plot_Ticks_Pos; 194 195 --------------------- 196 -- Creating a plot -- 197 --------------------- 198 199 procedure Gtk_New 200 (Plot : out Gtk_Plot; 201 Drawable : Gdk.Drawable.Gdk_Drawable := Gdk.Drawable.Null_Drawable); 202 -- Create a new plot, that will be displayed in Drawable. 203 -- All the dataset, labels, axis,... associated with the plot will be drawn 204 -- in that drawable, which must have been created beforehand. 205 -- Note that the drawable can also be set later with Set_Drawable. 206 207 procedure Gtk_New 208 (Plot : out Gtk_Plot; 209 Width : Gdouble; 210 Height : Gdouble; 211 Drawable : Gdk.Drawable.Gdk_Drawable := Gdk.Drawable.Null_Drawable); 212 -- Create a new plot with a specific size. 213 214 procedure Initialize 215 (Plot : access Gtk_Plot_Record'Class; 216 Drawable : Gdk.Drawable.Gdk_Drawable); 217 -- Internal initialization function. 218 -- See the section "Creating your own widgets" in the documentation. 219 220 procedure Initialize 221 (Plot : access Gtk_Plot_Record'Class; 222 Drawable : Gdk.Drawable.Gdk_Drawable; 223 Width : Gdouble; 224 Height : Gdouble); 225 -- Internal initialization function. 226 -- See the section "Creating your own widgets" in the documentation. 227 228 function Get_Type return Gtk.Gtk_Type; 229 -- Return the internal value associated with a Gtk_Plot. 230 231 procedure Set_Drawable 232 (Plot : access Gtk_Plot_Record; 233 Drawable : Gdk.Drawable.Gdk_Drawable); 234 -- Modify the drawable on which the graphs are displayed. 235 -- From now on, all the drawings will be done on that drawable. Note that 236 -- they are not automatically copied to the new Drawable until the Plot 237 -- needs to be redrawn. 238 239 function Get_Drawable 240 (Plot : access Gtk_Plot_Record) return Gdk.Drawable.Gdk_Drawable; 241 -- Return the drawable on which the graphs are plotted. 242 243 procedure Set_Background 244 (Plot : access Gtk_Plot_Record; 245 Background : Gdk.Color.Gdk_Color); 246 -- Change the background for the plot. 247 -- Note that this has no effect if the plot has been set to transparent 248 -- (see the flags below). 249 -- The Plot is also redrawn as soon as you modify this color. 250 251 procedure Set_Background_Pixmap 252 (Plot : access Gtk_Plot_Record; Pixmap : Gdk.Pixmap.Gdk_Pixmap); 253 -- Specificy a background pixmap to use for the plot 254 255 procedure Set_Transparent 256 (Plot : access Gtk_Plot_Record; Transparent : Boolean); 257 -- Whether the plot is transparent. If Transparent is True, all background 258 -- attributes are ignored (pixmap, color,...) 259 260 function Is_Transparent (Plot : access Gtk_Plot_Record) return Boolean; 261 -- Whether the plot is current transparent 262 263 procedure Paint (Plot : access Gtk_Plot_Record); 264 -- Force an immediate repaint of the widget in its pixmap. 265 -- The modification won't appear on the screen until you call Refresh. 266 -- It is probably not a good idea to call this function directly, and it 267 -- is more efficient to queue a draw request (see the Gtk.Widget package 268 -- for related functions). 269 270 procedure Refresh 271 (Plot : access Gtk_Plot_Record; 272 Area : Gdk.Rectangle.Gdk_Rectangle); 273 -- Copy the plot's pixmap to the screen. 274 -- The same comment as for Paint applies here, and you probably don't 275 -- have to call this function yourself, since queuing a draw request is 276 -- more efficient. 277 278 ---------------------------- 279 -- Coordinates and sizes -- 280 ---------------------------- 281 282 procedure Get_Position 283 (Plot : access Gtk_Plot_Record; 284 X : out Gdouble; 285 Y : out Gdouble); 286 -- Return the position of the Plot within its drawable. 287 -- X and Y are in the range 0.0 .. 1.0, where (0.0, 0.0) is the top-left 288 -- corner and (1.0, 1.0) the bottom-right corner. The position can be 289 -- modified by Move below. 290 291 procedure Get_Size 292 (Plot : access Gtk_Plot_Record; 293 Width : out Gdouble; 294 Height : out Gdouble); 295 -- Return the size of the Plot. 296 -- Width and Height are both in the range 0.0 .. 1.0, where 1.0 means they 297 -- occupy all the space available in the Drawable, 0.5 means they only 298 -- occupy half of it. 299 300 function Get_Internal_Allocation 301 (Plot : access Gtk_Plot_Record) return Gtk.Widget.Gtk_Allocation; 302 -- Return the real position/size of the plot inside its parent container. 303 -- You should use this function instead of converting yourself the result 304 -- of Get_Position and Get_Size. 305 306 procedure Set_Magnification 307 (Plot : access Gtk_Plot_Record; 308 Magnification : Gdouble); 309 -- Change the magnification level of the plot. 310 -- 1.0 is the default magnification, higher values will zoom in while lower 311 -- values will zoom out. 312 313 procedure Move 314 (Plot : access Gtk_Plot_Record; 315 X : Gdouble; 316 Y : Gdouble); 317 -- Move the plot widget inside its drawable. 318 -- X and Y should both be in the range 0.0 .. 1.0 (from top-left corner 319 -- to bottom-right corner). 320 321 procedure Resize 322 (Plot : access Gtk_Plot_Record; 323 Width : Gdouble; 324 Height : Gdouble); 325 -- Resize the widget. 326 -- Width and Height should both be in the range 0.0 .. 1.0, this indicates 327 -- which ratio of the drawable's screen real-estate they should use. 328 329 procedure Move_Resize 330 (Plot : access Gtk_Plot_Record; 331 X : Gdouble; 332 Y : Gdouble; 333 Width : Gdouble; 334 Height : Gdouble); 335 -- Move and resize the widget in a single operation. 336 -- This is faster than doing each operation separately. 337 338 procedure Get_Pixel 339 (Plot : access Gtk_Plot_Record; 340 Xx : Gdouble; 341 Yy : Gdouble; 342 X : out Gdouble; 343 Y : out Gdouble); 344 -- Get the screen coordinate (relative to Plot's parent) of a point. 345 -- The initial coordinates (Xx, Yy) should be in the range 0.0 .. 1.0. 346 347 procedure Clip_Data (Plot : access Gtk_Plot_Record; Clip : Boolean); 348 -- If Clip is True, any drawing of a Gtk_Plot_Data will be limited to the 349 -- area occupied by Plot. Otherwise, it might draw outside of Plot. 350 351 procedure Get_Point 352 (Plot : access Gtk_Plot_Record; 353 X : Gint; 354 Y : Gint; 355 Xx : out Gdouble; 356 Yy : out Gdouble); 357 -- Convert from an absolute screen coordinate to a relative one. 358 -- (X, Y) should be relative to Plot's parent. 359 -- This function is the opposite of Get_Pixel. 360 361 procedure Set_Xrange 362 (Plot : access Gtk_Plot_Record; 363 Xmin : Gdouble := 0.0; 364 Xmax : Gdouble := 1.0); 365 -- Set the range of visible points for this plot. 366 -- Only the points of the graph those coordinates are in the range 367 -- Xmin .. Xmax will be visible. 368 369 procedure Set_Yrange 370 (Plot : access Gtk_Plot_Record; 371 Ymin : Gdouble := 0.0; 372 Ymax : Gdouble := 1.0); 373 -- Set the range of visible points for this plot. 374 -- Only the points of the graph those coordinates are in the range 375 -- Xmin .. Xmax will be visible. 376 377 procedure Set_Range 378 (Plot : access Gtk_Plot_Record; 379 Xmin : Gdouble := 0.0; 380 Xmax : Gdouble := 1.0; 381 Ymin : Gdouble := 0.0; 382 Ymax : Gdouble := 1.0); 383 -- Set both ranges at the same time 384 385 procedure Autoscale (Plot : access Gtk_Plot_Record); 386 -- Calculate automically the appropriate ranges for the plot. 387 388 procedure Get_Xrange 389 (Plot : access Gtk_Plot_Record; 390 Xmin : out Gdouble; 391 Xmax : out Gdouble); 392 -- Get the current range for the X axis. 393 394 procedure Get_Yrange 395 (Plot : access Gtk_Plot_Record; 396 Ymin : out Gdouble; 397 Ymax : out Gdouble); 398 -- Get the current range for the X axis. 399 400 procedure Set_Xscale 401 (Plot : access Gtk_Plot_Record; 402 Scale_Type : Plot_Scale); 403 -- Set the type of the X axis (logarithmic, linear, ...). 404 405 procedure Set_Yscale 406 (Plot : access Gtk_Plot_Record; 407 Scale_Type : Plot_Scale); 408 -- Set the type of the Y axis (logarithmic, linear, ...). 409 410 function Get_Xscale 411 (Plot : access Gtk_Plot_Record) return Plot_Scale; 412 -- Get the type of the X axis. 413 414 function Get_Yscale 415 (Plot : access Gtk_Plot_Record) return Plot_Scale; 416 -- Get the type of the Y axis. 417 418 procedure Reflect_X (Plot : access Gtk_Plot_Record; Reflect : Boolean); 419 -- Reverse the direction of the X axis 420 421 function Is_X_Reflected (Plot : access Gtk_Plot_Record) return Boolean; 422 -- Whether the X axis is currently reflected 423 424 procedure Reflect_Y (Plot : access Gtk_Plot_Record; Reflect : Boolean); 425 -- Reverse the direction of the Y axis 426 427 function Is_Y_Reflected (Plot : access Gtk_Plot_Record) return Boolean; 428 -- Whether the Y axis is currently reflected 429 430 ---------- 431 -- Text -- 432 ---------- 433 434 function Put_Text 435 (Plot : access Gtk_Plot_Record; 436 X : Gdouble; 437 Y : Gdouble; 438 Font : String := ""; 439 Font_Height : Gint := 10; 440 Angle : Plot_Angle; 441 Foreground : Gdk.Color.Gdk_Color := Gdk.Color.Null_Color; 442 Background : Gdk.Color.Gdk_Color := Gdk.Color.Null_Color; 443 Transparent : Boolean := False; 444 Justification : Gtk.Enums.Gtk_Justification := Gtk.Enums.Justify_Center; 445 Text : String := "") return Gtk_Plot_Text; 446 -- Print some text in Plot. 447 -- The text will be drawn at the relative coordinates (X, Y), with a 448 -- specified Angle. 449 -- If Font is the empty string, a default font and default Font_Height 450 -- will be used. Likewise, default colors will be used if you don't 451 -- specify any. Font should be the name of a postscript font, the list of 452 -- which can be found in Gtk.Plot.Psfont. 453 -- If Transparent is True, then no background will be drawn for the text. 454 455 procedure Remove_Text 456 (Plot : access Gtk_Plot_Record; 457 Text : Gtk_Plot_Text); 458 -- Remove some text that is currently visible on the plot. 459 -- Nothing is done if Text is currently not visible. 460 461 procedure Text_Get_Area 462 (Text : Gtk_Plot_Text; 463 Angle : Plot_Angle; 464 Just : Gtk.Enums.Gtk_Justification; 465 Font_Name : String; 466 Font_Size : Gint; 467 X : out Gint; 468 Y : out Gint; 469 Width : out Gint; 470 Height : out Gint); 471 -- Return the area currently occupied by a text. 472 -- The coordinates are relative to the top-left corner of the plot in 473 -- which the text was put. 474 475 procedure Text_Get_Size 476 (Text : Gtk_Plot_Text; 477 Angle : Plot_Angle; 478 Font_Name : String; 479 Font_Size : Gint; 480 Width : out Gint; 481 Height : out Gint; 482 Ascent : out Gint; 483 Descent : out Gint); 484 -- Return the size in pixels occupied by a text in the plot. 485 -- See Gtk.Extra.Plot_Canvas for a function that returns a Gtk_Plot_Text. 486 487 procedure Text_Set_Attributes 488 (Text : Gtk_Plot_Text; 489 Font : String; 490 Height : Gint; 491 Angle : Plot_Angle; 492 Fg : Gdk.Color.Gdk_Color; 493 Bg : Gdk.Color.Gdk_Color; 494 Transparent : Boolean := False; 495 Justification : Gtk.Enums.Gtk_Justification := Gtk.Enums.Justify_Center; 496 Str : String := ""); 497 -- Change the attributes of Text. 498 499 procedure Text_Set_Border 500 (Text : Gtk_Plot_Text; 501 Border : Plot_Border_Style; 502 Border_Space : Gint; 503 Border_Width : Gint; 504 Shadow_Width : Gint); 505 -- Set the border attributes for the text 506 507 procedure Draw_Text 508 (Plot : access Gtk_Plot_Record; 509 Text : Gtk_Plot_Text); 510 -- Draw the text 511 512 ----------- 513 -- Lines -- 514 ----------- 515 516 procedure Draw_Line 517 (Plot : access Gtk_Plot_Record; 518 Line : Gtk_Plot_Line; 519 X1, Y1, X2, Y2 : Gdouble); 520 -- Draw a line on the plot 521 522 procedure Set_Line_Attributes 523 (Plot : access Gtk_Plot_Record; 524 Line : Gtk_Plot_Line); 525 526 ---------- 527 -- Axis -- 528 ---------- 529 -- A Gtk_Plot has four axis, one one each of its sides. These axis can 530 -- have ticks, labels for ticks, titles, ... associated with them. 531 532 procedure Set_Ticks 533 (Plot : access Gtk_Plot_Record; 534 Orientation : Plot_Orientation; 535 Major_Step : Gdouble; 536 Num_Minor : Gint); 537 -- Set up ticks for a specific orientation. 538 -- A horizontal orientation will match the left and right sides, whereas 539 -- a vertical orientation will match the top and bottom sides. 540 -- Major_Step is a value between 0.0 and 1.0 which indicates the 541 -- proportion of the total axis length between successive big ticks. 542 -- For instance, if Major_Step has a value of 0.2, there will be 5 big 543 -- ticks drawn along the axis. 544 -- Num_Minor is the number of minor ticks between each major one. 545 546 procedure Set_Major_Ticks 547 (Plot : access Gtk_Plot_Record; 548 Orientation : Plot_Orientation; 549 Major_Step : Gdouble); 550 -- Modify the step for major ticks. 551 -- Major_Step is a value between 0.0 and 1.0 which indicates the 552 -- proportion of the total axis length between successive big ticks. 553 -- For instance, if Major_Step has a value of 0.2, there will be 5 big 554 -- ticks drawn along the axis. 555 -- See also Set_Ticks. 556 557 procedure Set_Minor_Ticks 558 (Plot : access Gtk_Plot_Record; 559 Orientation : Plot_Orientation; 560 Num_Minor : Gint); 561 -- Modify the number of minor ticks between each major one. 562 -- See also Axis_Set_Ticks. 563 564 procedure Set_Ticks_Limits 565 (Plot : access Gtk_Plot_Record; 566 Orientation : Plot_Orientation; 567 Ticks_Begin : Gdouble; 568 Ticks_End : Gdouble); 569 -- Indicate the area of the axis that should have ticks. 570 -- Ticks will be displayed only from Ticks_Beg to Ticks_End. 571 572 procedure Unset_Ticks_Limits 573 (Plot : access Gtk_Plot_Record; 574 Orientation : Plot_Orientation); 575 -- Cancel the ticks limits set by a previous call to 576 -- Axis_Set_Ticks_Limits. 577 578 procedure Set_Break 579 (Plot : access Gtk_Plot_Record; 580 Orient : Plot_Orientation; 581 Min, Max : Gdouble; 582 Step_After : Gdouble; 583 Nminor_After : Gint; 584 Scale_After : Plot_Scale; 585 Pos : Gdouble); 586 -- ??? 587 588 procedure Remove_Break 589 (Plot : access Gtk_Plot_Record; Orient : Plot_Orientation); 590 -- ??? 591 592 procedure Gtk_New 593 (Axis : out Gtk_Plot_Axis; 594 Orientation : Plot_Orientation); 595 -- Create a new axis 596 597 procedure Initialize 598 (Axis : access Gtk_Plot_Axis_Record'Class; 599 Orientation : Plot_Orientation); 600 -- Internal initialization function. 601 -- See the section "Creating your own widgets" in the documentation. 602 603 function Axis_Get_Type return Gtk_Type; 604 -- Return the internal value associated with a Gtk_Plot_Axis. 605 606 function Get_Axis 607 (Plot : access Gtk_Plot_Record; 608 Axis : Plot_Axis_Pos) return Gtk_Plot_Axis; 609 -- Get a pointer to an axis. 610 611 function Gradient 612 (Data : access Gtk_Plot_Data_Record'Class) return Gtk_Plot_Axis; 613 -- Return the gradient associated with Data. 614 -- 615 -- This function cannot be defined in Gtk.Plot_Data, since Gtk_Plot_Axis 616 -- must be defined in the same package as its primitive operations, ie 617 -- Gtk.Plot 618 619 procedure Axis_Set_Visible 620 (Axis : access Gtk_Plot_Axis_Record; 621 Visible : Boolean); 622 -- Indicate whether the axis should be visible or not. 623 624 function Axis_Visible 625 (Axis : access Gtk_Plot_Axis_Record) return Boolean; 626 -- Return the visibility state of the axis 627 628 procedure Axis_Set_Title 629 (Axis : access Gtk_Plot_Axis_Record; 630 Title : String); 631 -- Modify the title of the axis. 632 -- Each axis has a title that is displayed along its line (vertically 633 -- for the left and right sides). 634 635 procedure Axis_Show_Title 636 (Axis : access Gtk_Plot_Axis_Record); 637 -- Show the title associated with the axis. 638 639 procedure Axis_Hide_Title 640 (Axis : access Gtk_Plot_Axis_Record); 641 -- Hide the title associated with the axis. 642 643 procedure Axis_Move_Title 644 (Axis : access Gtk_Plot_Axis_Record; 645 Angle : Plot_Angle; 646 X : Gdouble; 647 Y : Gdouble); 648 -- Modify the position and orientation of the axis' title. 649 -- X and Y indicate a position relative to the location of the axis (0.0 650 -- to display it to the left (resp. top) of the axis, 1.0 to display it 651 -- to the right (resp. bottom) of the axis. 652 653 procedure Axis_Justify_Title 654 (Axis : access Gtk_Plot_Axis_Record; 655 Justification : Gtk.Enums.Gtk_Justification); 656 -- Modify the justification for the axis. 657 658 procedure Axis_Set_Attributes 659 (Axis : access Gtk_Plot_Axis_Record; 660 Width : Gfloat; 661 Color : Gdk.Color.Gdk_Color); 662 -- Modify the attributes of the lines of the axis. 663 664 procedure Axis_Get_Attributes 665 (Axis : access Gtk_Plot_Axis_Record; 666 Width : out Gfloat; 667 Color : out Gdk.Color.Gdk_Color); 668 -- Get the attributes of the axis. 669 670 procedure Axis_Set_Ticks 671 (Axis : access Gtk_Plot_Axis_Record; 672 Major_Step : Gdouble; 673 Num_Minor : Gint); 674 -- Set up ticks for a specific orientation. 675 -- A horizontal orientation will match the left and right sides, whereas 676 -- a vertical orientation will match the top and bottom sides. 677 -- Major_Step is a value between 0.0 and 1.0 which indicates the 678 -- proportion of the total axis length between successive big ticks. 679 -- For instance, if Major_Step has a value of 0.2, there will be 5 big 680 -- ticks drawn along the axis. 681 682 procedure Axis_Set_Major_Ticks 683 (Axis : access Gtk_Plot_Axis_Record; 684 Major_Step : Gdouble); 685 -- Modify the step for major ticks. 686 -- Major_Step is a value between 0.0 and 1.0 which indicates the 687 -- proportion of the total axis length between successive big ticks. 688 -- For instance, if Major_Step has a value of 0.2, there will be 5 big 689 -- ticks drawn along the axis. 690 -- See also Axis_Set_Ticks. 691 692 procedure Axis_Set_Minor_Ticks 693 (Axis : access Gtk_Plot_Axis_Record; 694 Num_Minor : Gint); 695 -- Modify the number of minor ticks between each major one. 696 -- See also Axis_Set_Ticks. 697 698 procedure Axis_Set_Ticks_Length 699 (Axis : access Gtk_Plot_Axis_Record; 700 Length : Gint); 701 -- Set the length (in pixels) of the big ticks. 702 -- The small ticks will have half this length. 703 704 procedure Axis_Set_Ticks_Width 705 (Axis : access Gtk_Plot_Axis_Record; 706 Width : Gfloat); 707 -- Set the width (in pixels) of the ticks. 708 -- This width is common to both the long and short ticks. 709 710 procedure Axis_Show_Ticks 711 (Axis : access Gtk_Plot_Axis_Record; 712 Major_Mask : Plot_Ticks_Pos; 713 Minor_Mask : Plot_Ticks_Pos); 714 -- Set the style of the ticks. 715 716 procedure Axis_Set_Ticks_Limits 717 (Axis : access Gtk_Plot_Axis_Record; 718 Ticks_Begin : Gdouble; 719 Ticks_End : Gdouble); 720 -- Indicate the area of the axis that should have ticks. 721 -- Ticks will be displayed only from Ticks_Beg to Ticks_End. 722 723 procedure Axis_Unset_Ticks_Limits 724 (Axis : access Gtk_Plot_Axis_Record); 725 -- Cancel the ticks limits set by a previous call to 726 -- Axis_Set_Ticks_Limits. 727 728 procedure Axis_Set_Break 729 (Axis : access Gtk_Plot_Axis_Record; 730 Min, Max : Gdouble; 731 Step_After : Gdouble; 732 Nminor_After : Gint; 733 Scale_After : Plot_Scale; 734 Pos : Gdouble); 735 -- ??? 736 737 procedure Axis_Remove_Break (Axis : access Gtk_Plot_Axis_Record); 738 -- ??? 739 740 procedure Axis_Show_Labels 741 (Axis : access Gtk_Plot_Axis_Record; 742 Labels_Mask : Plot_Label_Pos); 743 -- Indicate whether a label should be drawn at each ticks to indicate 744 -- its value. 745 -- Not all values of Labels_Mask are relevant for all axis. For instance, 746 -- for a vertical axis, the relevant values are Axis_Right and Axis_Left. 747 748 procedure Axis_Title_Set_Attributes 749 (Axis : access Gtk_Plot_Axis_Record; 750 Font : String; 751 Height : Gint; 752 Angle : Plot_Angle; 753 Foreground : Gdk.Color.Gdk_Color; 754 Background : Gdk.Color.Gdk_Color; 755 Transparent : Boolean; 756 Justification : Gtk.Enums.Gtk_Justification); 757 -- Set the attributes to be used for the title of the axis. 758 -- Font is a postscript font name (as listed in the beginning of this 759 -- package). 760 761 procedure Axis_Set_Labels_Attributes 762 (Axis : access Gtk_Plot_Axis_Record; 763 Font : String; 764 Height : Gint; 765 Angle : Plot_Angle; 766 Foreground : Gdk.Color.Gdk_Color; 767 Background : Gdk.Color.Gdk_Color; 768 Transparent : Boolean; 769 Justification : Gtk.Enums.Gtk_Justification); 770 -- Set the attributes to be used for the ticks labels. 771 772 procedure Axis_Set_Labels_Offset 773 (Axis : access Gtk_Plot_Axis_Record; 774 Offset : Gint); 775 -- Set the distance between the axis and its labels 776 777 function Axis_Get_Labels_Offset 778 (Axis : access Gtk_Plot_Axis_Record) return Gint; 779 -- Get the distance between the axis and its labels. 780 781 procedure Axis_Set_Labels_Style 782 (Axis : access Gtk_Plot_Axis_Record; 783 Style : Plot_Label_Style; 784 Precision : Gint); 785 -- Set the style of labels. 786 -- This indicates whether the labels should be displayed as floating 787 -- point values or in the scientific notation. 788 -- Precision is the number of digits to be printed. 789 790 procedure Axis_Use_Custom_Tick_Labels 791 (Axis : access Gtk_Plot_Axis_Record; 792 Custom : Boolean := True); 793 -- Indicate which kind of labels should be used for major ticks. 794 -- If Custom is True, then the labels set by Axis_Set_Tick_Labels will 795 -- be used. 796 797 procedure Axis_Set_Labels_Suffix 798 (Axis : access Gtk_Plot_Axis_Record; 799 Text : String); 800 -- Defines a suffix to add after each label on the axis 801 802 procedure Axis_Set_Labels_Prefix 803 (Axis : access Gtk_Plot_Axis_Record; 804 Text : String); 805 -- Defines a prefix to add before each label on the axis 806 807 function Axis_Get_Labels_Suffix 808 (Axis : access Gtk_Plot_Axis_Record) return String; 809 -- Return the suffix added to each label. 810 811 function Axis_Get_Labels_Prefix 812 (Axis : access Gtk_Plot_Axis_Record) return String; 813 -- Return the prefix added to each label. 814 815 procedure Axis_Ticks_Recalc (Axis : access Gtk_Plot_Axis_Record); 816 817 function Axis_Ticks_Transform 818 (Axis : access Gtk_Plot_Axis_Record; 819 Y : Gdouble) return Gdouble; 820 821 function Axis_Ticks_Inverse 822 (Axis : access Gtk_Plot_Axis_Record; 823 X : Gdouble) return Gdouble; 824 825 procedure Axis_Parse_Label 826 (Axis : access Gtk_Plot_Axis_Record; 827 Val : Gdouble; 828 Precision : Gint; 829 Style : Gint; 830 Label : String); 831 832 ----------- 833 -- Grids -- 834 ----------- 835 -- A grid can be displayed in the graph. 836 -- This makes it easier to understand a graphics in some situations. 837 -- The grid has two simultaneous line styles, each with its own specific 838 -- step (minor and major steps). 839 -- 840 -- There are two special lines in the grid, that you can display even if 841 -- you don't display the rest of the line. These are the origin of the 842 -- coordinates system, ie the lines at X=0 and Y=0. 843 844 procedure X0_Set_Visible 845 (Plot : access Gtk_Plot_Record; 846 Visible : Boolean); 847 -- Indicate whether the line at X=0 should be displayed. 848 849 function X0_Visible 850 (Plot : access Gtk_Plot_Record) return Boolean; 851 -- Return the visibility state of the line at X=0 852 853 procedure Y0_Set_Visible 854 (Plot : access Gtk_Plot_Record; 855 Visible : Boolean); 856 -- Indicate whether the line at Y=0 should be displayed. 857 858 function Y0_Visible 859 (Plot : access Gtk_Plot_Record) return Boolean; 860 -- Return the visibility state of the line at Y=0 861 862 procedure X0line_Set_Attributes 863 (Plot : access Gtk_Plot_Record; 864 Style : Plot_Line_Style; 865 Width : Gfloat; 866 Color : Gdk.Color.Gdk_Color); 867 -- Set the attributes of the line at X=0 868 869 procedure Y0line_Set_Attributes 870 (Plot : access Gtk_Plot_Record; 871 Style : Plot_Line_Style; 872 Width : Gfloat; 873 Color : Gdk.Color.Gdk_Color); 874 -- Set the attributes of the line at Y=0 875 876 procedure Grids_Set_On_Top 877 (Plot : access Gtk_Plot_Record; On_Top : Boolean); 878 -- Whether the grid should be displayed on top of the plots 879 880 function Grids_On_Top (Plot : access Gtk_Plot_Record) return Boolean; 881 -- Whether the gris is currently displayed on top of the plots 882 883 procedure Grids_Set_Visible 884 (Plot : access Gtk_Plot_Record; 885 Vmajor : Boolean; 886 Vminor : Boolean; 887 Hmajor : Boolean; 888 Hminor : Boolean); 889 -- Indicate whether the lines of the grids should be displayed. 890 -- You can decide separately whether the major and minor lines should 891 -- be displayed. 892 893 procedure Grids_Visible 894 (Plot : access Gtk_Plot_Record; 895 Vmajor : out Boolean; 896 Vminor : out Boolean; 897 Hmajor : out Boolean; 898 Hminor : out Boolean); 899 -- Return the visibility state of the grid. 900 901 procedure Major_Hgrid_Set_Attributes 902 (Plot : access Gtk_Plot_Record; 903 Style : Plot_Line_Style; 904 Width : Gfloat; 905 Color : Gdk.Color.Gdk_Color); 906 -- Set the attributes for the major horizontal lines in the grid. 907 908 procedure Major_Vgrid_Set_Attributes 909 (Plot : access Gtk_Plot_Record; 910 Style : Plot_Line_Style; 911 Width : Gfloat; 912 Color : Gdk.Color.Gdk_Color); 913 -- Set the attributes for the major vertical lines in the grid. 914 915 procedure Minor_Hgrid_Set_Attributes 916 (Plot : access Gtk_Plot_Record; 917 Style : Plot_Line_Style; 918 Width : Gfloat; 919 Color : Gdk.Color.Gdk_Color); 920 -- Set the attributes for the minor horizontal lines in the grid. 921 922 procedure Minor_Vgrid_Set_Attributes 923 (Plot : access Gtk_Plot_Record; 924 Style : Plot_Line_Style; 925 Width : Gfloat; 926 Color : Gdk.Color.Gdk_Color); 927 -- Set the attributes for the minor vertical lines in the grid. 928 929 ------------- 930 -- Legends -- 931 ------------- 932 -- Each graph is associated with one legend, that is supposed to 933 -- indicate what the plot represents. 934 935 procedure Show_Legends (Plot : access Gtk_Plot_Record); 936 -- Indicate that the legend should be displayed. 937 938 procedure Hide_Legends (Plot : access Gtk_Plot_Record); 939 -- Indicate that the legend should not be displayed. 940 941 procedure Set_Legends_Border 942 (Plot : access Gtk_Plot_Record; 943 Border : Plot_Border_Style; 944 Shadow_Width : Gint); 945 -- Modify the way the borders of the legend look like. 946 947 procedure Legends_Move 948 (Plot : access Gtk_Plot_Record; 949 X : Gdouble; 950 Y : Gdouble); 951 -- Move the legend relative to the widget's area. 952 -- X and Y are percentage values. (0.0, 0.0) indicates the top-left 953 -- corner of the plot, (1.0, 1.0) indicates the bottom-right corner. 954 955 procedure Legends_Get_Position 956 (Plot : access Gtk_Plot_Record; 957 X : out Gdouble; 958 Y : out Gdouble); 959 -- Return the current position of the legend. 960 961 function Legends_Get_Allocation 962 (Plot : access Gtk_Plot_Record) return Gtk.Widget.Gtk_Allocation; 963 -- Return the exact coordinates and size in pixels of the legend. 964 -- The coordinates are relative to the widget's parent container. 965 966 procedure Legends_Set_Attributes 967 (Plot : access Gtk_Plot_Record; 968 Ps_Font : String; 969 Height : Gint; 970 Foreground : Gdk.Color.Gdk_Color; 971 Background : Gdk.Color.Gdk_Color); 972 -- Set the attributes to use when displaying the legend. 973 974 -------------- 975 -- Datasets -- 976 -------------- 977 -- A dataset is a set of points, either given explicitly by your 978 -- application or calculated with a specific function, and that can be 979 -- plotted on the screen. 980 -- In Gtk_Plot, such a set is represented with symbols (special points in 981 -- the graph, that can be manipulated interactively if you so wish), linked 982 -- by connectors, which are either straight lines, splines, sets, ... 983 -- Multiple data sets can of course be printed on a single graph. 984 985 -- <doc_ignore> 986 generic 987 with function Func (Plot : access Gtk_Plot_Record'Class; 988 Set : Gtk_Plot_Data; 989 X : Gdouble; 990 Error : access Boolean) 991 return Gdouble; 992 function Generic_Plot_Function (Plot : System.Address; 993 Set : Gtk_Plot_Data; 994 X : Gdouble; 995 Error : access Gboolean) 996 return Gdouble; 997 -- Generic function that can be instantiated for Plot_Function below. 998 -- </doc_ignore> 999 1000 -- <doc_ignore> 1001 generic 1002 with function Func (Plot : access Gtk_Plot_Record'Class; 1003 Set : Gtk_Plot_Data; 1004 X : Gdouble; 1005 Y : Gdouble; 1006 Error : access Boolean) 1007 return Gdouble; 1008 function Generic_Plot3D_Function (Plot : System.Address; 1009 Set : Gtk_Plot_Data; 1010 X : Gdouble; 1011 Y : Gdouble; 1012 Error : access Gboolean) 1013 return Gdouble; 1014 -- Generic function that can be instanciated for Plot3D_Function below. 1015 -- </doc_ignore> 1016 1017 type Plot3D_Function is access function 1018 (Plot : System.Address; 1019 Set : Gtk_Plot_Data; 1020 X : Gdouble; 1021 Y : Gdouble; 1022 Error : access Gboolean) return Gdouble; 1023 -- Function used for plotting 3D graphs. 1024 -- It should return the value associated with (X, Y) in its graph, and set 1025 -- Error to True if there was an error while calculating the value. 1026 1027 pragma Convention (C, Generic_Plot_Function); 1028 pragma Convention (C, Generic_Plot3D_Function); 1029 pragma Convention (C, Plot3D_Function); 1030 1031 procedure Add_Data 1032 (Plot : access Gtk_Plot_Record; 1033 Data : access Gtk_Plot_Data_Record'Class); 1034 -- Add an existing set of data to the plot. 1035 -- This set will automatically be drawn the next time the Plot itself is 1036 -- drawn. 1037 1038 function Remove_Data 1039 (Plot : access Gtk_Plot_Record; 1040 Data : access Gtk_Plot_Data_Record'Class) 1041 return Boolean; 1042 -- Remove the dataset from Plot. 1043 -- This function returns True if the dataset was indeed found and could be 1044 -- removed, False otherwise. 1045 1046 function Add_Function 1047 (Plot : access Gtk_Plot_Record; 1048 Func : Plot_Function) 1049 return Gtk_Plot_Data; 1050 -- Allocate a new dataset, whose point are automatically calculated. 1051 -- Func is a function that takes the X coordinate value, and should return 1052 -- the Y coordinate value. 1053 -- The newly allocated set should be freed by calling Free above. 1054 -- The set is automatically added to the plot, so you don't need to 1055 -- explicitly call Add_Dataset. 1056 1057 ------------- 1058 -- Signals -- 1059 ------------- 1060 1061 -- <signals> 1062 -- The following new signals are defined for this widget: 1063 -- 1064 -- - "changed" 1065 -- procedure Handler (Plot : access Gtk_Plot_Record'Class); 1066 -- 1067 -- Called every time some property of the widget is changed, or the 1068 -- widget is moved or resized. 1069 -- 1070 -- - "moved" 1071 -- function Handler (Plot : access Gtk_Plot_Record'Class; 1072 -- X : Gdouble; 1073 -- Y : Gdouble) 1074 -- return Boolean; 1075 -- 1076 -- Called when the widget has been moved relative to its drawable. 1077 -- Its new position is given in parameters. 1078 -- 1079 -- - "resized" 1080 -- function Handler (Plot : access Gtk_Plot_Record'Class; 1081 -- Width : Gdouble; 1082 -- Height : Gdouble) 1083 -- return Boolean; 1084 -- 1085 -- Called when the widget has been resized relative to its drawable. 1086 -- Its new size is given in parameters. 1087 -- 1088 -- - "tick_label" 1089 -- function Handler (Axis : access Gtk_Plot_Axis_Record'Class; 1090 -- Tick : Gdouble_Access; 1091 -- Label : Interfaces.C.Strings.chars_ptr) 1092 -- return Boolean; 1093 -- 1094 -- Called when a label should be drawn. You can modify the contents 1095 -- of Label (up to 100 characters) a 1096 -- 1097 -- </signals> 1098 1099private 1100 type Gtk_Plot_Record is new Gtk.Widget.Gtk_Widget_Record with null record; 1101 type Gtk_Plot_Axis_Record is new Glib.Object.GObject_Record with 1102 null record; 1103 1104 Label_None : constant Plot_Label_Pos := 0; 1105 Label_In : constant Plot_Label_Pos := 1; 1106 Label_Out : constant Plot_Label_Pos := 2; 1107 1108 Ticks_None : constant Plot_Ticks_Pos := 0; 1109 Ticks_In : constant Plot_Ticks_Pos := 1; 1110 Ticks_Out : constant Plot_Ticks_Pos := 2; 1111 1112 pragma Import (C, Get_Type, "gtk_plot_get_type"); 1113 pragma Import (C, Axis_Get_Type, "gtk_plot_axis_get_type"); 1114 pragma Import (C, Text_Set_Border, "gtk_plot_text_set_border"); 1115end Gtk.Extra.Plot; 1116 1117-- Unbound: 1118-- gtk_plot_set_pc 1119-- gtk_plot_axis_set_tick_labels 1120-- gtk_plot_axis_ticks_autoscale 1121