Function:xs2qpa
From S2PLOT
Revision as of 06:27, 6 March 2008; view current revision
←Older revision | Newer revision→
←Older revision | Newer revision→
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
xs2cp | Select a panel for subsequent geometry calls. | |
xs2ap | Add a new panel. | |
xs2mp | Modify location of existing panel. | |
xs2tp | Toggle visibility of panel. | |
xs2lpc | Link panel cameras together. | |
xs2qsp | Query currently selected panel. | |
xs2qcpa | Is currently selected panel active? |
Code Example
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "s2plot.h"
/* Global variable */
int pid = 0; /* Which panel should be drawn? */
int panel0; /* ID of the master panel */
int panel1, panel2; /* IDs of newly created panels */
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 = 6; /* Counter */
count--; /* Decrease counter */
int active; /* ID of panel to change */
if (count < 0) { /* Time to reset counter */
if (drand48() > 0.5) { /* Choose a random panel */
active = panel1;
} else {
active = panel2;
}
if (drand48() > 0.5) /* Random toggle panel activity */
xs2tp(active);
count = 6; /* Reset the counter */
}
}
int vis1 = xs2qpa(panel1); /* Query visibility of panel with ID */
int vis2 = xs2qpa(panel2); /* Query visibility of panel with ID */
s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0); /* Draw coordinate box */
char string[32];
if (myid == panel0) { /* Is this the master panel? */
if (vis1 && vis2) { /* Prepare an appropraite string */
sprintf(string,"Active panels %d %d",panel1,panel2);
} else if (vis1) {
sprintf(string,"Active panels %d",panel1);
} else if (vis2) {
sprintf(string,"Active panels %d",panel2);
} else {
sprintf(string,"No active panels");
}
} else {
sprintf(string,"I am panel %d",myid);
}
s2textxy(-1,0,0,string); /* Write the string */
}
int main(int argc, char *argv[])
{
srand48((long)time(NULL)); /* Seed random numbers */
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.