Function:s2qwc

From S2PLOT

Revision as of 02:13, 29 August 2011; view current revision
←Older revision | Newer revision→
Jump to: navigation, search

s2qwc

Query the window clipping mode.

Prototype

int s2qwc(void);

Description

Query whether clipping is being applied to geometry. When enabled, clipping means points not within the world coordinate bounds as defined by the most recent call to s2swin, will not be drawn. The initial implementation applies to points only, future work may apply the clipping to lines and facets as well. Enable/disable/toggle (1,0,-1) clipping.

See Also

s2swcSet the window clipping mode.

Code Example

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "s2plot.h"

void cb(double *t, int *kc)
{
   int N = 100;                                 /* Number of points */
   static int flag = -1;                        /* Flag for initialisation */
   static XYZ xyz[100];                         /* Array of point positions */
   static COLOUR col[100];                      /* Array of colours */
   int i;                                       /* Loop variable */

   if (flag < 0) {                              /* First time through? */
      for (i=0;i<N;i++) {
         xyz[i].x = drand48()*2.0 - 1.0;        /* Random data positions */
         xyz[i].y = drand48()*2.0 - 1.0;
         xyz[i].z = drand48()*2.0 - 1.0;
         col[i].r = drand48();                  /* Random data colours */
         col[i].g = drand48();
         col[i].b = drand48();
      }
      flag = 1;                                 /* Set the flag */
   }

   s2swin(-0.8,0.8,-0.8,0.8,-0.8,0.8);          /* Set new plotting window */

   for (i=0;i<N;i++) {
      ns2vthpoint(xyz[i], col[i], 3);           /* Draw the point */
   }

   if (*kc % 2 == 1)                            /* Check for keyboard press */
      s2twc(1);                                 /* Turn on clipping */
   else
      s2twc(0);                                 /* Turn off clipping */

   int wc = s2qwc();                            /* Query clipping state */
   char text[32];
   sprintf(text, "Clipping state: %d\n",wc);    /* Prepare a text string */
   s2textxy(0.0,0.0,0.0, text);                 /* Display text string */

   s2lab("","","","Press <space> to toggle clipping state");
}

int main(int argc, char *argv[])
{

   srand48((long)time(NULL));                   /* Seed random numbers */

   s2opend("/?",argc, argv);                    /* Open the display */
   s2swin(-1.,1., -1.,1., -1.,1.);              /* Set the window coordinates */
   s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0);  /* Draw coordinate box */

   cs2scb(cb);                                  /* Install a dynamic callback */

   s2show(1);                                   /* Open the s2plot window */


   return 1;
}

Back to S2PLOT function list.


Personal tools