go to www.geomview.org home page



Mailing List

Geomview For Windows?


Bug Reporting
Contact Us



Site Search



About the software@geom archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

No Subject

> (1) I am using a geomview external module similar to example 1 in
> the manual. Currently I have an oscillating family of surfaces
> which I would like to interrupt from the keyboard (like hitting
> Control-C), have the module stop so I can play with it (using
> the geomview controls), and then start up again (by another keystroke). 

Geomview has taken control of the keyboard in a sense;
you could arrange for your program to get input from the
terminal anyway, but for a situation like this one,
you could use a simple trick.  For more elaborate controls
it probably would be worth using a FORMS interface.

Your program can ask geomview to notify it when
something is typed in one of the geomview graphic windows.
For example, if your module prints
	(interest (rawevent 32))

(where "32" is the decimal ASCII code for a space)
then geomview will send a message like
	(rawevent 32  1 792 615 1172918)
whenever you press the space bar in a graphics window.

To make use of this, your program might be structured as follows.
Instead of a simple loop like

   while(1) {

you might say

   printf("(interest (rawevent 32))"); fflush(stdout);

   while(1) {
       int paused = 0;
       int needack;

	/* Send a token to geomview; when it receives this,
	 * it will send a "+" back on our standard input.
	printf("(echo +)"); fflush(stdout);


	/* Wait for the "+" to return; this prevents us
	 * from getting too far ahead of geomview.
	 * At the same time, watch for other messages, like
	 * a (rawevent ...) report.  We could actually parse these,
	 * but for now let's just count the ')'s.
	needack = 1;
	while(needack || paused) {
	    c = getchar();
	    if(c == '+')
		needack = 0;	     /* Geomview's done with previous stuff */
	    if(c == ')')
		paused = !paused;    /* Toggle "paused" once per (rawevent) */
	    if(c == EOF)
		exit(1);	     /* Geomview terminated somehow. */
	    /* Ignore anything else. */

With code like this, each time you press the space bar (in a graphics window,
not the terminal window where you started geomview!), the module will
alternately pause or resume displaying.

Home | Overview | FAQ | Documentation | Support | Download | Mailing List
Windows? | Development | Bug Reporting | Contributing | Contact Us | Sponsors
site hosted by
SourceForge Logo