Function:xs2qsp

From S2PLOT

(Difference between revisions)
Jump to: navigation, search
Revision as of 03:23, 4 December 2007
S2plot admin (Talk | contribs)

← Previous diff
Current revision
S2plot admin (Talk | contribs)

Line 62: Line 62:
cs2scb(&cb); /* Install a dynamic callback */ cs2scb(&cb); /* Install a dynamic callback */
- panel1 = xs2ap(0.0, 0.0, 0.5, 0.5); /* Create panel in bottom right */+ panel1 = xs2ap(0.0, 0.0, 0.5, 0.5); /* Create panel in bottom left */
xs2cp(panel1); /* Choose this panel */ xs2cp(panel1); /* Choose this panel */
s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */ s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */
cs2scb(&cb); /* Install a dynamic callback */ cs2scb(&cb); /* Install a dynamic callback */
- panel2 = xs2ap(0.5, 0.0, 1.0, 0.5); /* Create panel in bottom left */+ panel2 = xs2ap(0.5, 0.0, 1.0, 0.5); /* Create panel in bottom right */
xs2cp(panel2); /* Choose this panel */ xs2cp(panel2); /* Choose this panel */
s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */ s2swin(-1.,1., -1.,1., -1.,1.); /* Set the window coordinates */

Current revision

xs2qsp

Which is the currently selected panel?

Prototype

int xs2qsp(void);

Description

In static mode, which panel is currently the chosen panel (using xs2cp)? In dynamic mode, what is the panel number of the callback that is currently being processed?

See Also

xs2cpSelect a panel for subsequent geometry calls.
xs2mpModify location of existing panel.
xs2qpaIs specified panel active?
xs2qcpaIs currently selected panel active?

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.


Personal tools