Prev: color.html Up Next: grob.html
Object hierarchy

Blop is written in C++, so object hierarchy can have the following meanings:


Object hierarchy in a figure

Objects in a plot are organized in a containment hierarchy: certain objects (like canvas, pad, frame) are containers, which can contain other objects (other containers as well). The center of the coordinate system within a container is its lower left corner. The extension of the container's coordinate system within its parent can be obtained via the member functions cleft(), cbottom(), cheight(), etc. The position of the objects can be set also (see somewhere else), and it can also be read using member functions of these objects like left(), bottom(), etc. These functions return a length, which is to be understood as the distance from the parent's origin in the horizontal or vertical direction. A container's outer extension (that is, the region it occupies within its parent, and which is returned by the member functions left(), bottom(), etc) does not have to be the same as the region that it defines as its coordinate system, and the extension of which is returned by the member functions cleft(), etc. For example a pads inner coordinate system (in which its contents are printed) is smaller by the borderwith of the pad, than its whole size.

The topmost element in the object hierarchy is a canvas. This is the root of this hierarchy, all other objects must be contained in a canvas, or in another object (which is finally contained in a canvas). A canvas is a virtual something, it exists only in the computer's memory. In order to realize it, you have to print it to some terminal (see somewhere else). You can have several canvases at the same time. You always have an active canvas, which is accessible via the canvas::current() function, which returns a reference to the active canvas.

You can specify a sub-area of a canvas by creating a pad inside the canvas (or inside any other pad). This object is a container, and it does nothing else than specifies a rectangular area within its parent, and all its contents will be printed within this rectangular area. You have an active pad, all plotting or other commands (see somewhere else) work on the active pad. The active pad is accessible via the function pad::current(), which returns a reference to the active pad. A canvas is also a pad, if you don't create any subpad within a canvas, your active canvas and active pad are the same: this canvas.

Within a pad (or the canvas) you normally have a frame. This object provides 4 axes (two horizontal ones: x1 (lower) and x2 (upper), and two vertical ones: y1 (left) and y2 (right)). You can have several frames within a pad. Your active frame is accessible via frame::current().

All the above containers (canvas, pad, frame) can contain graphical objects (grobs). For example text labels, which are created by one of the following functions:

label::pdraw(var  text, length  x, length  y);  // draw into current pad
label::fdraw(var  text, length  x, length  y);  // draw into current frame
label::cdraw(var  text, length  x, length  y);  // draw into current canvas
(these functions create a text label and add it into the currently active pad, frame or canvas ==> hence the initial 'p', 'f' or 'c' in the function names)

Graphs are special since they need a reference frame, so they can only be put into a frame. The plot(...) functions create and put graphs into the current frame.


Class inheritance

... under construction, browse the source files instead.


Prev: color.html Up Next: grob.html