+++ to secure your transactions use the Bitcoin Mixer Service +++

 


School of Computer Science
The University of Birmingham

Examples of what can be done
with the Pop-11 RCLIB package
For 2-D graphical interfaces

School of Comuter Science
The University of Birmingham, UK

Note: This is part of the Free Poplog web site.


CONTENTS


Introduction

RCLIB is a 2-D graphical interface package available as an addition to the Poplog software development system. "RC" stands for "Relative Coordinates": all the graphical commands are relative to a frame of reference, which can be changed without altering the commands, making it easy to draw the same thing in different parts of a display, using different sizes or orientations, and possibly stretched or sheared.

The RCLIB package is used in several of the SimAgent toolkit libraries and demonstrations.

RCLIB is implemented using the language Pop-11, the core language of Poplog. (A Pop-11 Primer is online here), Pop-11 is a multi-paradigm language with power comparable to Common Lisp, but with a syntax that many people, including many students, find more familiar.

RCLIB builds on the very much simpler RC_GRAPHIC package in Pop-11, which can be used to provide introductory tutorials on various topics illustrated graphically. Some simple examples of the use of RC_GRAPHIC are here.

The rc_control_panel procedure demonstrated below is one of many facilities defined in the RCLIB package, which supports easily definable panels and displays of various types, along with facilities for moving 2-D images.

The RCLIB package is based on Objectclass, the Object Oriented extension to Pop-11, which supports multiple inheritance and generic functions. (Somewhat like CLOS in Common Lisp).

Some tutorial information about the Pop-11 Objectclass package is available in these three directories. here

RCLIB uses the X Window System

RCLIB uses the low level interface between Pop-11 and the X window graphical system. Pop-11 includes many X utilities (including some written in C and invoked from Pop-11). Those utilities are extremely general and powerful, including asynchronous event handling, so that mouse and keyboard events can interact with running programs. But they are quite hard for novice programmers to use in writing programs because they are low level facilities, and using them requires a lot of knowledge about the X window system. RCLIB provides a level of abstraction that hides most of the messy details, making easy things very easy and very hard things much less hard!

Pop-11's RC_GRAPHIC (Relative Coordinates Graphic) library and the RCLIB package are implemented on top of those utilities and provide an intuitive and relatively easy to use programming toolkit, for which it is not necessary to read X manuals. I.e. RCLIB hides most of the details that have to be specfied to interact with the X window system.

Of course, advanced programmers can extend the RCLIB facilities using the lower level tools: although the details are not exposed in RCLIB, they remain available through the Pop-11 libraries used by RCLIB. Because RCLIB is implemented in Pop-11, Pop-11 programmers can easily modify or extend the tools, or copy and edit source files to produce their own tools, without having to switch to C programming.

The rc_control_panel procedure demonstrated below is just one of many procedures included in RCLIB to make interactive programming, testing, and debugging easy. It allows a panel to be specified declaratively, leaving out much of the messy detail (e.g. precise locations of buttons and sub-panels). The required co-ordinates are computed by rc_control_panel on the basis of the declarative specifications.

RCLIB and SIMAGENT

In conjunction with the SimAgent toolkit, RCLIB enables agent simulations to include 2-D moving objects which can be moved either by the mouse or by processes in a simulation. There are some MPEG movies illustrating the use of RCLIB with SimAgent here: http://www.cs.bham.ac.uk/research/poplog/figs/simagent/

MORE INFORMATION ON RCLIB

A plain text overview file on RCLIB can be found here: http://www.cs.bham.ac.uk/research/poplog/rclib/help/rclib Additional rclib documentation is available in the help, teach and ref documentation files here.

RCLIB, like everything else in Poplog, is freely available open source code, available from the Free Poplog web site (URL below).


Simple uses of RCLIB

A new graphical window for inserting drawings, buttons, sliders, text panels, etc. is created by this command, including the graphical windows shown below.
    ;;; Declare a variable called win1 and give it a window
    vars win1 =rc_new_window_object(600, 10, 400, 400, true, 'WIN1');
As in LOGO, this Pop-11 loop instruction will draw a square. repeat 4 times rc_draw(100); rc_turn(90); endrepeat; We can turn that into a definition of a re-usable procedure.
    define rc_square(side);
        repeat 4 times rc_draw(side); rc_turn(90); endrepeat;
    enddefine;
This will draw 12 squares differing in orientation by 30 degrees, with a common corner.
    repeat 12 times rc_square(100); rc_turn(30); endrepeat;
To show them being drawn individually, insert a delay: 50 hundredths of a second = half a second.
    rc_clear_window_object(win1);
    repeat 12 times rc_square(100); rc_turn(30); syssleep(50); endrepeat;
Drawing faces using RCLIB
The SimAgent package includes a library for drawing a few simple types of face. It can be loaded thus:
    uses newkit
    uses sim_faces
It can then be used to draw nine different faces thus:
    ;;; create a window called 'WIN1' with top left corner at location
    ;;; (600,10) on the screen, and size 600x600 pixels.
    ;;; Assign the new window to the variable win1.
    vars win1 =rc_new_window_object(600, 10, 600, 600, true, 'WIN1');

    ;;; Now draw nine faces in three rows and three columns:

    happy_face(-200, 200, 80, 'red', 20, 35, 50, 'blue', 'pink');

    happy_face(0, 200, 60, 'orange', 22, 20, 55, 'blue', 'white');

    sad_face(200, 200, 75, 'black', 30, 25, 40, 'white', 'white');

    sad_face(-200, 0, 75, 'black', 30, 25, 60, 'white', 'yellow');

    frustrated_face(0, 0, 86, 'blue', 30, 30, 70, 'grey70', 'grey40');

    frustrated_face(200, 0, 90, 'blue', 35, 35, 76, 'pink', 'yellow');

    neutral_face(-200, -200, 100, 'green', 38, 45, 80, 'blue', 'red');

    neutral_face(0, -200, 95, 'gray', 35, 45, 90, 'white', 'black');

    surprised_face(200, -200, 90, 'orange', 32, 35, 75, 'grey', 'white');
The result of those commands is shown here:

Nine faces

Possible exercise

A student could be shown a subset of invocations of one of the face_drawing proceedures and invited to experiment to find out which numbers control which aspects of the face picture and what the strings with colour names correspond to in the drawing.

A non-computing student enjoyed experimenting with the happy_face procedure, varying the parameters, until she had worked out that the parameters specified in order:

    o Horizontal and Vertical coordinates of the centre of the face
        (with position  (0,0) referring to the centre of the window)

    o Radius of the whole face

    o Colour of the whole face

    o Radius of each eye

    o A radius corresponding to the size of the mouth

    o The distance between the centres of the eyes

    o The colour of the eyes

    o The colour of the mouth.
After that, she was able to use her knowledge to draw a collection of different faces.

RC_CONTROL_PANEL

The RCLIB library, like most Pop-11 packages, includes many documentation files and tutorial files all easily accessible from within the Poplog editor VED. One of the tutorial files 'TEACH RC_CONTROL_PANEL' shows how to create the panel shown below. This is done by creating a list of lists, where each list specifies declaratively a field of the panel.

The 'field specs' list starts with some global specifications of properties of the whole panel, e.g. minimum width, default background and foreground colours, fonts, etc. Only a subset of the possible field types are shown in this example.

Since all the facilities used in such a panel are defined in Pop-11 they are very easily changed, including being re-defined while a program is running, which supports very rapid debugging and development because it uses an incremental compiler as part of its run-time system.

After the list, field_specs, has been defined as described in the TEACH file, the following Pop-11 command

vars panel = rc_control_panel("right", "top", field_specs, 'Demo Panel');
can be used to create a panel as shown in the figure.

[Display produced by rc_control_panel]

NOTE The colours and layout are merely examples. Since everything is programmed in pop-11, colours, fonts, sizes of components, and other features are easily specified by the programmer. RCLIB does not depend on Motif or any other toolkit.

The slider values and values shown on dials can be altered using the mouse. Actions can be associated with changes to the values. Variables associated with the counter button and toggle button at the bottom will have their values automatically altered if the mouse is used to alter the values. Likewise programs changing values of the variables can also alter the display.

The teach file showing how to do this is a plain text file designed for use in an editor which interacts with the Pop-11 compiler. It can be found here:
http://www.cs.bham.ac.uk/research/poplog/rclib/teach/rc_control_panel

A more complete and detailed specification of rc_control_panel is here (over 3000 lines):
http://www.cs.bham.ac.uk/research/poplog/rclib/help/rc_control_panel
Most users will never need more than a small subset of the facilities provided. It has proved very useful for producing control panels in a number of student projects.

The bottom row shows a "counter" button which controls a stored numeric value which goes up or down depending whether you click with button 1 or button 3. It also shows a "toggle" button which switches a boolean value.

Finally it shows an action button which destroys the window.

The panel layout is automatically produced by rc_control_panel from the specifications of the individual fields and their order in the list. Thus user does not need to compute the width or height of the panel required to include all the fields, nor where each field is located.

The panel displayed on the screen is represented by a Pop-11 data-structure which has associated event handlers that can invoke Pop-11 programs, e.g. to draw things, run programs, create new panels, modify global variables, launch unix programs, etc.

The data-structure is returned as the result of rc_control_panel. The above instruction causes the variable panel to be declared, and the result assigned to it. So the value of the variable is the panel. This means that programs can access and update the components of the panel.

It is very easy to alter defaults, such as button sizes, font sizes or colours, panel backgrounds, etc.

More detailed information about RCLIB classes and procedures can be found in the help and teach sub-directories of the RCLIB package: http://www.cs.bham.ac.uk/research/poplog/rclib/

To find out more about Pop-11 see the online primer http://www.cs.bham.ac.uk/research/poplog/primer/


Installation test

When you install poplog version 15.6 or later versions the $usepop/bin/demos directory includes a command to test pop-11 by running the SIM_FEELINGS demo. This is what the resulting screen looked like after a user had installed and tested it, allowing the red and blue agents to run until they were both happily located next to their 'targets'.

Sim_Feelings display

Full size version of 'screenshot'.


XVED and the RCMENU package

Poplog includes a multi-window text editor XVed which can be used for producing code and documentation and for reading online help and teach files, or browsing the source code directories. The editor is written in Pop-11 and is therefore very extendable (like Emacs, which is implemented in Lisp. It can also be used to launch programs and can function as an interface to programs.

The editor can be used with and without Motif. If you have Motif installed on your system, XVed will include a scroll bar and a number of fairly conventional pull-down menus as shown near the top of this display of one of its windows, opened for browsing an online tutorial file. (The example shows white font on a black background. This is one of many options available.)

[Display of an XVed window]

The example above shows a rather small XVed window, with 73 columns and 21 rows of text. However, larger or smaller windows can be used, and the font size can be altered to suit your eyesight and screen resolution.


The recursive hypermenu extension to Ved and XVed

There is a "dumb terminal" version of the editor, Ved, which does not use multiple windows, though many files can be edited simultaneously, with only two editor buffers visible at a time, in an Xterm window.

Ved does not support the pull-down menus provided in XVed. However the optional "Recursive Hypermenu" package, implemented on the basis of the RCLIB package (described above) can be invoked from either Ved or XVed and does not depend on the availability of Motif, as it uses only generic X window capabilities.

The menu package can be invoked by the "menu" command as shown in the 'command line' in the example above, or can be made to appear automatically when the editor is started up, or it can be invoked by a program.

[Two of the default Recursive Hypermenus]

By default the 'menu' command invokes a "Toplevel" menu panel with a collection of buttons that can be used to invoke other panels which in turn can invoke further panels or perform actions.

The example above shows how the Toplevel panel can be used to invoke the Compiling panel. If the Toplevel panel is dismissed it can be brought back by clicking on the "Menus" button of any other panel. In other words, these menu panels can invoke one another, hence they are recursive. They are also autoloadable. I.e. it is not necessary to pre-compile all the menus that may be required. Rather, if a menu button is selected which invokes a certain menu panel, then the code for the panel will be looked for in one of a set of menu directories. If found it will be compiled and the menu displayed. If it had previously been displayed and then dismissed it will be re-displayed without being re-compiled.

During development of a menu panel the code can be repeatedly edited and re-compiled, and each time the displayed panel will removed and a new one corresponding to the new definition will be displayed. This can speed up development and testing of an interface enormously. Different users can have their own sub-directories with menus that extend or re-define those provided in the core directory.


The RCLIB File Browser

In the example display of menus accessible from Ved, one of the buttons (at the top of the third column) is labelled 'BrowseFiles*'.
This button invokes a file browser program that makes use of patterns for file names. There is a brief description of it, posted to a poplog forum in 1999, here.

Example using RCLIB in a tutorial on neural nets
(Produced by Riccardo Poli)

The code in the Pop-11 library rc_neural.p defines a procedure that can be given a list defining a neural net structure, with sample input output values to be used to train the net.

The result of producing a net with three inputs and one output and training it to be the 'majority' function is shown in the picture.

Rc_neural display


Example RCMENU definitions

The code for the Toplevel menu, the Compiling menu, and many more can be found in this directory, which is part of the RCMENU package. http://www.cs.bham.ac.uk/research/poplog/rcmenu/menus.

Note that the menu with name xxx is defined in the file with name menu_xxx.p
Some of the menus launch unix programs because the buttons can invoke arbitrary Pop-11 procedures, and Pop-11 can invoke shell scripts, C programs, etc.

More detailed information about the RCMENU package can be found in the help and teach sub-directoris of the RCLIB package: http://www.cs.bham.ac.uk/research/poplog/rcmenu/
The program code (which depends on RCLIB) can be found in the auto and menus sub-directories.


A neural net design tool

The next figure shows part of the graphical interface to a neural net design tool. This package was implemented by Matthias Scheutz, using control panels produced by RCLIB.

The main control panel on the left causes the other panels to be displayed or hidden.

The other panels to the right of it use sliders to show inputs and outputs of the various layers in the network.

The panel below, containing dials represents weights in part of the network.

[Neural net design tool GUI]
The inputs, outputs and weights can be altered using the mouse to move the sliders or the dials. For a given setting the "Propagate" buttons on the main control panel can be used to run the net for 1, 10 or 100 cycles. Many of the sliders are then seen to move. The dials can be changed to alter the weights.

If a network with desired properties is found, then its specification can be saved in a file, in a textual form for later re-use. A saved file can be reloaded into the package later.

Each of the panels is a separate window on the screen and they can be moved around with the mouse. The panel borders and title bars are generated by the X window manager, according to the user's preferences. In this case the ctwm window manager was used.

Please note, this was a 'toy' demonstration produced by Matthias Scheutz while he was learning to use Pop-11, RCLIB and the Sim_agent toolkit.

More recently he has designed and implemented the Simworld package based on Sim_agent and using RCLIB for its graphical interface.


Examples from TEACH RC_GRAPHPLOT showing graphical output.

TO BE EXTENDED ....

For more on Poplog and Pop-11 see the Free Poplog site.

The following files give pointers to information about the complete Poplog system, which includes incremental compilers for four languages, Pop-11, Common Lisp, Prolog, and Standard ML, all implemented in the core language Pop-11.
http://www.cs.bham.ac.uk/research/poplog/freepoplog.html
and
http://www.cs.bham.ac.uk/research/poplog/poplog.info.html

A downloadable package including Poplog and the Birmingham additions for use on 32 bit Linux + PC is here
http://www.cs.bham.ac.uk/research/projects/poplog/latest-poplog

Ways of running Poplog on Windows (e.g. using VirtualBox) are described here
http://www.cs.bham.ac.uk/research/projects/poplog/ova/

Examples of "Thinky" programming in Pop-11 are here
http://www.cs.bham.ac.uk/research/projects/poplog/examples

An online primer on Pop-11 can be found here http://www.cs.bham.ac.uk/research/poplog/primer

Objectclass provides multiple inheritance and generic functions, and is used throughout the SimAgent toolkit

Text files documenting Objectclass can be found in these directories:
http://www.cs.bham.ac.uk/research/poplog/doc/objectclassteach
http://www.cs.bham.ac.uk/research/poplog/doc/objectclassdocs
http://www.cs.bham.ac.uk/research/poplog/doc/objectclasshelp
http://www.cs.bham.ac.uk/research/poplog/doc/objectclassref


Images produced using TGIF

The .gif images shown above were all produced using the 'screen capture' facility of the tgif package, a small, fast, versatile, user-friendly and FREE package which runs under the X window system.

Tgif can be used for preparing diagrams, for capturing screen images to be inserted in diagrams, and also for preparing and presenting slide presentations with "active" regions, and more besides. (I.e. it has much of the functionality of powerpoint.) It can save diagrams in many formats, including "eps" for inclusion in other documents. Tgif is freely available for linux and unix systems from:


Last updated: 22 Jul 2009; 28 Sep 2010; 25 Oct 2011; 4 Jul 2019 (minor)

Maintained by Aaron Sloman