Function:xs2qpa
From S2PLOT
(Difference between revisions)
Revision as of 03:45, 4 December 2007
xs2qpa
Is specified panel active?
Prototype
int xs2qpa(int panelid);
Description
Is the specified panel active? Activity of a panel is modified using xs2tp. In dynamic mode, the callback is disabled if the panel is inactive.
See Also
s2open | . |
Code Example
#include <stdio.h>
#include <stdlib.h>
#include "s2plot.h"
/* Global variable */
int pid = 0; /* Which panel should be drawn? */
int panel0; /* ID of the master panel */
void cb(double *t, int *kc)
{
int myid = xs2qsp(); /* Query the panel id currently being drawn */
if (myid == panel0) { /* Is this the main panel? */
static int count = 8; /* Counter */
if (count < 0) { /* Is it time to choose a new panel */
pid = random()%3; /* Choose a random new panel */
count = 8; /* Reset the counter */
}
count--; /* Decrease counter */
}
if (myid == pid) { /* If this panel is the selected panel... */
s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0); /* Draw coordinate box */
char string[32];
sprintf(string,"I am panel %d",myid); /* Prepare a string */
s2textxy(-1,0,0,string); /* Write the string */
}
}
int main(int argc, char *argv[])
{
int panel1; /* ID of newly created panel */
int panel2; /* ID of newly created panel */
s2opend("/s2mono", argc, argv); /* Open in mono mode */
s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */
panel0 = xs2qsp(); /* Get the ID of the master panel */
xs2mp(panel0, 0.0, 0.5, 1.0, 1.0); /* Move default panel to top left */
cs2scb(&cb); /* Install a dynamic callback */
panel1 = xs2ap(0.0, 0.0, 0.5, 0.5); /* Create panel in bottom left */
xs2cp(panel1); /* Choose this panel */
s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */
cs2scb(&cb); /* Install a dynamic callback */
panel2 = xs2ap(0.5, 0.0, 1.0, 0.5); /* Create panel in bottom right */
xs2cp(panel2); /* Choose this panel */
s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */
cs2scb(&cb); /* Install a dynamic callback */
xs2cp(panel0); /* Go back to main panel */
s2sch(2); /* Set the character height */
s2show(1); /* Open the s2plot window */
return 1;
}
Back to S2PLOT function list.