Example #1
0
int main(int argc, char *argv[])
{
   XYZ xyz = { 0.0, 0.0, 0.0 };			/* Position */
   XYZ right = { 0.05, 0.0, 0.0 };		/* Right vector */
   XYZ up = { 0.0, 0.05, 0.0 };			/* Up vector */
   COLOUR col = { 1.0, 1.0, 0.0 };		/* Colour */
   char text[32];				/* Text */
   float sp = 5.0;				/* Speed */

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

   sp = ss2qss();				/* Get spin speed */
   sprintf(text,"Speed = %5.2f",sp);		/* Prepare the text */
   ns2vtext(xyz, right, up, col, text);		/* Right some text */
  
   s2lab("","","","Use * and / to control the spin speed");

   ss2sas(1);					/* Start camera rotating */

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Example #2
0
int main(int argc, char *argv[])
{

   srand48((long)time(NULL));                   /* Seed random numbers */
   s2opend("/s2mono",argc, argv);		/* Open the display: mono */
   s2swin(-1.,1., -1.,1., -1.,1.);		/* Set the window coordinates */
   s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);	/* Draw coordinate box */

   s2lab("","","","Press < and > to change camera movement increment, then +/- to test zooming\n"); 

   cs2scb(cb);					/* Install dynamic callback */
   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Example #3
0
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[128];				/* Write instruction label */
   sprintf(string,"Press 1 to protect, press 2 to unprotect");
   s2lab("","","",string);

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Example #4
0
nemo_main()
{
    permanent bool first=TRUE;
    int argc = 1;
    static char *argv[] = {"snaps2plot", NULL};
    float size = 1.0;
    extern string yapp_string;

    setparams();

    /* also:  check env var S2PLOT_DEV */
#if 0
    s2opend("/?", argc, argv);
#else
    s2opendo(yapp_string);
#endif
    s2swin((float)xrange[0], (float)xrange[1], 
	   (float)yrange[0], (float)yrange[1], 
	   (float)zrange[0], (float)zrange[1]);
    s2box(s2box_opt,0,0,s2box_opt,0,0,s2box_opt,0,0);
    s2lab(xlabel,ylabel,zlabel,input);


    instr = stropen(input, "r");
    get_history(instr);
    compfuncs();
#ifdef COLOR
    setcolors();
#endif
    while (scansnap()) {
	if (! trakflag) {
	  if (first) {
	    first = FALSE;
	  } else {
	    sleep(FRAMEDELAY);
	    plframe();
	  } 
	}
	plotsnap();
	warning("Can only do first selected snapshot");
	s2show(1);
	/* how to clear and advance to next snapshot */
    }
}
Example #5
0
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");
}
Example #6
0
int main(int argc, char *argv[])
{
   char xopt[] = "BCDETMNOPQ";
   char yopt[] = "BCDETMNOPQ";
   char zopt[] = "BCDETMNOPQ";

   s2opend("/?",argc, argv);			/* Open the display */
   s2swin(-1.,1., -1.,1., -1.,1.);		/* Set the window coordinates */
   s2box(xopt, 0,0, yopt, 0,0, zopt, 0,0);	/* Draw the coordinate box */
   s2lab("X-axis","Y-axis","Z-axis","Plot");	/* Write some labels */

   XYZ xyz1 = { -0.8, -0.8, -0.8 };		/* Box coordinate */
   XYZ xyz2 = { +0.8, +0.8, +0.8 };		/* Box coordinate */
   COLOUR col = { 1.0, 0.3, 0.2 };		/* RGB colours */

   float alpha = 0.4;				/* Alpha channel transparency */

   ns2vscube(xyz1, xyz2, col, alpha);

   s2show(1);					/* Open the s2plot window */
   
   return 1;
}
Example #7
0
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 */
   }

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

   static int lkc = 1;				/* Last time <space> key pressed */
   if (lkc != *kc) 				/* Check for keyboard press */
      ss2sca(drand48()*70 + 20);		/* Set the camera aperture */
   lkc = *kc;					/* Update key press */

   int wc = ss2qca();				/* Query camera aperture */
   char text[64];				
   sprintf(text, "Aperture %d degrees\n",wc);	/* Prepare a text string */
   s2textxy(0.0,0.0,0.0, text);			/* Display text string */

   s2lab("","","","Press <space> to change camera aperture");
}
Example #8
0
void cb(double *t, int *kc)
/* Dynamic callback function */
{
   XYZ rot; 
   int wc = 1;				/* Use world coordinates */
   XYZ off = { 0.01, 0.01, 0.0 };	/* Small offset for text */

   int set;
   char string[255];
   s2sch(0.05);				/* Set the text height */
   if (*kc%2 == 0) {
      ss2qpr(&rot, wc);			/* Query the rotation point */ 
      sprintf(string,"Rotation about (%.2f, %.2f, %.2f)",rot.x,rot.y,rot.z);
      XYZ xyz = { 0.5, 0.5, 0.5 };
      ss2scf(xyz, wc);			/* Set the camera focus */
   } else {
      ss2qcf(&set, &rot, wc);		/* Query the camera focus */
      sprintf(string,"Focus at (%.2f, %.2f, %.2f)",rot.x,rot.y,rot.z);
   }
   ds2vtb(rot, off,string,1);		/* Write some dynamic billboard text */
   s2lab("","","","<space> to toggle mode");
					/* Display an instructional label */

}