Function:cs2qhv

From S2PLOT

Jump to: navigation, search

cs2qhv

Query whether selection handles are currently visible

Prototype

int cs2qhv(void);

Description

Query the current state of the selection handle visibility. Returns 0 if handles are disabled or 1 if handles are enabled.

See Also

cs2shcb Set the handle callback function for when a handle is (de)selected
cs2thv Toggle the current state of selection handles


Code Example

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

#define N 100                   /* Number of points */

XYZ xyz[N];                     /* Global variable: positions */
COLOUR col[N];                  /* Colour of the point */
int sel[N];                     /* Global varibale: selected data */

void cb(double *t, int *kc)
{
   COLOUR hilite = { 1.0, 1.0, 1.0 };           /* Highlight colour */
   float hsize = 0.02;                          /* Size of handle */
   int i;                                       /* Loop variable */
   char string[64];                             /* Label to draw */
   int vis;                                     /* Handle visibility */

   vis = cs2qhv();                              /* Query handle state */
   sprintf(string,"Cntrl-S to toggle handles.  Currently: %d\n",vis);
   s2lab("","","",string);                      /* Write the label */

   for (i=0;i<N;i++) {
      ns2vthpoint(xyz[i], col[i], 3);                /* Draw thick point */
      ds2ah(xyz[i], hsize, col[i], hilite, i, sel[i]);
                                                    /* Draw handles */
   }
}

int main(int argc, char *argv[])
{
   int i;                                       /* Loop varibale */
   float x, y, z;                               /* Random data */

   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 */

   for (i=0;i<N;i++) {                          /* Set-up globals */
      xyz[i].x = drand48()*2.0 - 1.0;           /* Random position */
      xyz[i].y = drand48()*2.0 - 1.0;
      xyz[i].z = drand48()*2.0 - 1.0;
      col[i].r = drand48();                     /* Random colour */
      col[i].g = drand48();
      col[i].b = drand48();
      sel[i]   = 0;                             /* Not currently selected */
   }

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

   s2slw(2);                                    /* Set line width */
   for (i=0;i<N;i++) {          /* Non-selectable random data points */
      x = drand48()*2.0 - 1.0;
      y = drand48()*2.0 - 1.0;
      z = drand48()*2.0 - 1.0;
      s2sci(15*drand48() + 1);                  /* Random colour */
      s2pt1(x,y,z,1);
   }

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

   return 1;
}

Back to S2PLOT function list.


Personal tools