Function:ds2isprotected

From S2PLOT

Jump to: navigation, search

ds2isprotected

Query state of dynamic geometry protection.

Prototype

void ds2isprotected(void);

Description

Query whether dynamic geometry is currently protected.

See Also

ds2protectProtect dynamic geometry.
ds2unprotectUnprotect the dynamic geometry.

Code Example

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

void ncb(int *N)
{
   int pstate = ds2isprotected();               /* What is current protection state? */

   if ((*N == 1) && (pstate == 0)) {            /* Key 1 was pressed */
      ds2protect();                             /* Protect dynamic geometry */
   }
   if ((*N == 2) && (pstate == 1)) {            /* Key 2 was pressed */
      ds2unprotect();                           /* Unprotect dynamic geometry */
   }
}

void cb(double *t, int *kc)
{
   static XYZ orbit;                            /* Position of point to draw */
   static float tt = 0;                         /* Current position in orbit */
   orbit.x = cos(tt);                           /* Update point position */
   orbit.y = sin(tt);
   tt += 0.05;

   COLOUR ocol = { 1, 1, 0 };                   /* Point colour = yellow*/
   ns2vthpoint(orbit, ocol,  3);                /* Draw the point */

}

int main(int argc, char *argv[])
{
   srand48((long)time(NULL));                   /* Seed random numbers */
   s2opend("/?", argc, argv);                   /* Prompt for display type */
   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 dynamic geometry callback */
   cs2sncb(ncb);                                /* Install number key press callback */

   char string[32];                             /* Write instruction label */
   sprintf(string,"Press 1 to protect, press 2 to unprotect");
   s2lab("","","",string);

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

   return 1;
}

Back to S2PLOT function list.


Personal tools