Esempio n. 1
0
static void drawslider(gl_slider *sl) {
    Int32 lw = getlwidth();
    Int32 cl = getcolor();
    Int32 oriwin = winget();
    long co;
    int i;
    Screencoord x, y;
    Int32 xo, yo;
    
    winset(sl->win);
    linewidth(1);
   
    update_slider_value(sl);
    locate_slider(sl);
    
    if (sl->txbg == -1) {
	/* first time, get bg color */
	cmov2(sl->x + sl->len + sl->thick, sl->y);
	getcpos(&x, &y);
	getorigin(&xo, &yo);
	x -= xo;
	y -= yo;
	i = lrectread(x, y, x, y, &co);
	sl->txbg = co;
#ifdef DEBUG
	printf("textbg = %d, bytes = %d x %d (soll %g) y %d (soll %g)\n",
	       co,i,x,sl->x + sl->len + sl->thick,
	       y,sl->y);	
#endif
    }
    color(sl->bg);
    rectf(sl->x, sl->y, sl->x+sl->thick+sl->len, sl->y+sl->height);
    color(sl->fg);
    rect (sl->x, sl->y, sl->x+sl->thick+sl->len, sl->y+sl->height);
    rectf(sl->x + sl->len * (sl->value - sl->min)/(sl->max - sl->min),
	  sl->y,
	  sl->x + sl->len * (sl->value - sl->min)/(sl->max - sl->min) + sl->thick,
	  sl->y + sl->height);
    if (sl->buf != NULL) {
	color(sl->txbg);
	cmov2(sl->x + sl->len + sl->thick, sl->y);
	charstr(sl->buf);
	color(sl->fg);
	sprintf(sl->buf + 1, sl->format, sl->value);
	cmov2(sl->x + sl->len + sl->thick, sl->y);
	charstr(sl->buf);
    }
    
    winset(oriwin);
    color(cl);
    linewidth(lw);
    
    sleep(0);
}
Esempio n. 2
0
static void drawbutton(gl_button *bt) {
    Int32 lw = getlwidth();
    Int32 cl = getcolor();
    Int32 oriwin = winget();
    int cfg, bg;
    
    winset(bt->win);
    linewidth(1);
    locate_button(bt);
    
    cfg = *(bt->state)?bt->bg:bt->fg;
    bg  = *(bt->state)?((bt->type == BUTTON)?bt->fg:bt->active_c):bt->bg;
	
    color(bg);
    rectf(bt->x, bt->y, bt->x + bt->width, bt->y + bt->height);
    
    color(bt->fg);
    rect (bt->x, bt->y, bt->x + bt->width, bt->y + bt->height);

    if (bt->label != NULL) {
	color(cfg);
	cmov2(bt->x, bt->y + 0.05 * bt->height);
	charstr(bt->label);
    }
    
    winset(oriwin);
    color(cl);
    linewidth(lw);
    
    sleep(0);
}
Esempio n. 3
0
static void   locate_button(gl_button *bt) {
    /* awful hacks to get coordinates in screencoords */

    Screencoord xs, ys;
    Int32 xo, yo;
    
    getorigin(&xo, &yo);

    cmov2(bt->x, bt->y);
    getcpos(&xs, &ys);
    bt->scx0 = (int)xs - xo;
    bt->scy1 = (int)ys - yo;
    
#ifdef DEBUG
    printf("locate_button: getcpos gives x = %d y = %d for %g, %g\n",
	   (int)xs, (int)ys, bt->x, bt->y);
#endif
    
    cmov2(bt->x + bt->width, bt->y + bt ->height);
    getcpos(&xs, &ys);
    bt->scx1 = (int)xs - xo;
    bt->scy0 = (int)ys - yo;
}        
Esempio n. 4
0
static void   locate_slider(gl_slider *sl) {
    /* awful hacks to get coordinates in screencoords */

    Screencoord xs, ys;
    Int32 xo, yo;

    getorigin(&xo, &yo);

    cmov2(sl->x, sl->y);
    getcpos(&xs, &ys);
    sl->scx0 = (int)xs - xo;
    sl->scy1 = (int)ys - yo;
    
    cmov2(sl->x + sl->len, sl->y + sl ->height);
    getcpos(&xs, &ys);
    sl->scx1 = (int)xs - xo;
    sl->scy0 = (int)ys - yo;
    
    cmov2(sl->x + sl->thick, sl->y);
    getcpos(&xs, &ys);
    sl->sc_thick = (int)xs - xo - sl->scx0;

}        
Esempio n. 5
0
/*----------------------------------------------------------------------
----------------------------------------------------------------------*/
void vDrawHelp()
{
 
  	float x = 0.0, y = 0.0, z = -10.0;
	float r_x = 0.0, r_y = 0.0, r_z = -10.0;
	float xang = 0.0, yang = 180.0, zang = 0.0;
	float wang = 0.0, bgang = 0.0;
	float lx = 0.0, ly = CHAN_Y/2.0 + 0.5, lz = -12.0;
	int st_time, titxang = 0;
   Matrix mat;
   long prev_mode;
   char str[30];
   fmfonthandle font1, font2;
	int len = strlen(Message);
	static i = 0;
	int j;
	float tmp;
	const int instr_num = 21;
	char mesg[21][100] =
	{
		"         View            Key",
		" ",
		  "        pilot           pad 7",
		  "        behind          pad 8",
		  "        behind-up       pad 4",
		  "        top             pad 5",
		" ",
		" ",
		"  Usage                               Key",
		" ",
      "                1st setting         2nd setting         3rd setting",
		" ",
		"downward        up arrow            down arrow          down arrow",
    	"upward          down arrow          up arrow            up arrow",
    	"leftward        left arrow          left arrow          left arrow",
    	"rightward       right arrow         right arrow         right arrow",
    	"left turn       pad number 2        pad number 0        akey",
    	"right turn      pad number 3        pad number period   skey",
    	"nitro           pad number 0        pad number 3        zkey",
    	"break           pad number period   pad number 2        xkey",
    	"fire            pad enter           pad enter           dkey",
	};


	#ifdef DOFF
		printf("draw help\n");
	#endif
    glClearColor(1,1,1,1);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    

	glPushMatrix();

	gluLookAt(0.3, 1.0, -8.0, r_x, r_y, r_z, 0);
	setup_lig();
	vDrawLight(GL_LIGHT0, GL_LIGHT0, lx, ly, lz);
	vDrawBody(-8.2, 0.0, 0.0, 0.0, x,y,z, 0.0, 180.0, 0.0, 0.0);

	glPushMatrix();
	tmp = Speed;
	Speed = 0.0;
   	vDrawChannel(FALSE);
   	vDrawSqs();
	Speed = tmp;
	glPopMatrix();

	glPopMatrix();


    glPushMatrix();
   glLoadIdentity();
   prev_mode = glGetIntegerv(GL_MATRIX_MODE);
   glMatrixMode(GL_PROJECTION);
   glGetIntegerf(GL_PROJECTION_MATRIX, mat);;

    	glColor3fv(fBlueVec);
   		ortho2(-160, 160, -130, 130);
 
		for (j=0; j<instr_num; j++)
		{
   			cmov2(-150, 100-j*10);
   			charstr(mesg[j]);
		}
 
   glLoadMatrixf(mat);
   glMatrixMode(prev_mode);
   glPopMatrix();


    glutSwapBuffers();
    glFlush();
}
Esempio n. 6
0
/*
 * using curves
 */
main()
{
	char	dev[20];
	int	i;
	short	val;

	vinit("mswin");
	winopen("curves");

	qdevice(KEYBD);
	unqdevice(INPUTCHANGE);
	/* 
	 * Wait for REDRAW event ...
	 */
	while (qread(&val) != REDRAW)
		;

	ortho2(-200.0, 400.0, -100.0, 500.0);

	color(BLACK);
	clear();

	color(YELLOW);

	/*
	 * label the control points in geom1
	 */
        for (i = 0; i < 4; i++) {
		cmov2(geom1[i][0], geom1[i][1]);
		sprintf(dev, "%d", i);
		charstr(dev);
	}
								 
	/*
	 * label the control points in geom2
	 */
	for (i = 0; i < 6; i++) {
		cmov2(geom2[i][0], geom2[i][1]);
		sprintf(dev, "%d", i);
		charstr(dev);
	}

	/*
	 * set the number of line segments appearing in each curve to 20
	 */
	curveprecision((short)20);

	/*
	 * copy the bezier basis matrix into the basis matrix stack and
	 * set the curve basis accordingly.
	 */
	defbasis((short)1, bezier);
	curvebasis((short)1);

	color(RED);

	/*
	 * draw a curve using the current basis matrix (bezier in this case)
	 * and the control points in geom1
	 */
	crv(geom1);

	cmov2(70.0, 60.0);
	charstr("Bezier Curve Segment");

	cmov2(-190.0, 450.0);
	charstr("Three overlapping Bezier Curves");

	/*
	 * crvn draws overlapping curve segments according to geom2, the
	 * number of curve segments drawn is three less than the number of
	 * points passed, assuming there are a least four points in the
	 * geometry matrix (in this case geom2). This call will draw 3
	 * overlapping curve segments in the current basis matrix - still
	 * bezier.
	 */
	crvn(6L, geom2);

	qread(&val);

	/*
	 * load in the cardinal basis matrix
	 */
	defbasis((short)1, cardinal);
	curvebasis((short)1);

	color(MAGENTA);

	cmov2(70.0, 10.0);
	charstr("Cardinal Curve Segment");

	/*
	 * plot out a curve segment using the cardinal basis matrix
	 */
	crv(geom1);

	cmov2(-190.0, 400.0);
	charstr("Three overlapping Cardinal Curves");

	/*
	 * now draw a bunch of them again.
	 */
	crvn(6L, geom2);

	qread(&val);

	/*
	 * change the basis matrix again
	 */
	defbasis((short)1, bspline);
	curvebasis((short)1);

	color(GREEN);

	cmov2(70.0, -40.0);
	charstr("Bspline Curve Segment");

	/*
	 * now draw our curve segment in the new basis...
	 */
	crv(geom1);

	cmov2(-190.0, 350.0);
	charstr("Three overlapping Bspline Curves");

	/*
	 * ...and do some overlapping ones
	 */
	crvn(6L, geom2);

	qread(&val);

	gexit();
}
static void 
_dxf_DRAW_GNOMON (tdmInteractor I, void *udata, float rot[4][4], int draw)
{
  /*
   *  draw == 1 to draw gnomon, draw == 0 to undraw.  This is done with
   *  two separate calls in order to support explicit erasure of edges for
   *  some implementations.  A draw is always preceded by an undraw and
   *  the pair of invocations is atomic.
   *
   *  Computations are done in normalized screen coordinates in order to
   *  render arrow heads correctly.
   */

  DEFDATA(I,tdmRotateData) ;
  DEFPORT(I_PORT_HANDLE) ;
  int dummy = 0 ;
  float origin[2] ;
  float xaxis[2],  yaxis[2],  zaxis[2] ;
  float xlabel[2], ylabel[2], zlabel[2] ;

  ENTRY(("_dxf_DRAW_GNOMON (0x%x, 0x%x, 0x%x, %d)",I, udata, rot, draw));

  if (PDATA(font) == -1)
    {
      /* font width for axes labels in normalized coordinates */
      font(0) ;
      PDATA(font) = 0 ;
      PDATA(swidth) = (float)strwidth("Z")/(float)GNOMONRADIUS ;

      /* 1 pixel in normalized coordinates */
      PDATA(nudge) = 1.0/(float)GNOMONRADIUS ;
    }
  else
      font(PDATA(font)) ;
  
  if (draw)
    {
      lmcolor(LMC_COLOR) ;
      cpack(0xffffffff) ;
      linewidth(1) ;
    }
  else
    {
      if (PDATA(redrawmode) != tdmViewEchoMode)
	{
	  /*
	   *  In tdmViewEchoMode (DX's Execute On Change), we are drawing
	   *  the gnomon echo on top of a background image that is redrawn
	   *  with every frame of a direct interaction.
	   *
	   *  If we're not in that mode, the background image is static
	   *  while the gnomon echo rotates in front of it, so erasing the
	   *  gnomon means we have to repair damage to the background.  We
	   *  do this by blitting a portion of the static image to the
	   *  back buffer, drawing the gnomon over that, then blitting the
	   *  combined results back to the front buffer.
	   */
	  
	  /* force graphics output into back buffer */
	  frontbuffer(FALSE) ;
	  backbuffer(TRUE) ;
	  
	  /* erase gnomon background */
	  lrectwrite (PDATA(illx), PDATA(illy),
		      PDATA(iurx), PDATA(iury), PDATA(background)) ;
	}

#ifndef NOSHADOW      
      /* draw wide black lines to ensure visibility against background */
      lmcolor(LMC_COLOR) ;
      cpack(0x0) ;
      linewidth(2) ;
#else
      EXIT(("No shadow"));
      return ;
#endif
    }

  origin[0] = 0 ;
  origin[1] = 0 ;

  xaxis[0] = 0.7 * rot[0][0] ; xaxis[1] = 0.7 * rot[0][1] ;
  yaxis[0] = 0.7 * rot[1][0] ; yaxis[1] = 0.7 * rot[1][1] ;
  zaxis[0] = 0.7 * rot[2][0] ; zaxis[1] = 0.7 * rot[2][1] ;

  xlabel[0] = 0.8 * rot[0][0] ; xlabel[1] = 0.8 * rot[0][1] ;
  ylabel[0] = 0.8 * rot[1][0] ; ylabel[1] = 0.8 * rot[1][1] ;
  zlabel[0] = 0.8 * rot[2][0] ; zlabel[1] = 0.8 * rot[2][1] ;

  pushmatrix() ;
  loadmatrix(identity) ;
  bgnline() ; v2f(origin) ; v2f(xaxis) ; endline() ;
  _dxf_DRAW_ARROWHEAD(PORT_CTX, xaxis[0], xaxis[1]) ;

  bgnline() ; v2f(origin) ; v2f(yaxis) ; endline() ;
  _dxf_DRAW_ARROWHEAD(PORT_CTX, yaxis[0], yaxis[1]) ;

  bgnline() ; v2f(origin) ; v2f(zaxis) ; endline() ;
  _dxf_DRAW_ARROWHEAD(PORT_CTX, zaxis[0], zaxis[1]) ;
  
  if (xlabel[0] <= 0) xlabel[0] -= PDATA(swidth) ;
  if (xlabel[1] <= 0) xlabel[1] -= PDATA(swidth) ;
  
  if (ylabel[0] <= 0) ylabel[0] -= PDATA(swidth) ;
  if (ylabel[1] <= 0) ylabel[1] -= PDATA(swidth) ;
  
  if (zlabel[0] <= 0) zlabel[0] -= PDATA(swidth) ;
  if (zlabel[1] <= 0) zlabel[1] -= PDATA(swidth) ;

#ifndef NOSHADOW  
  if (!draw)
    {
      /* offset text slightly for shadow */
      xlabel[0] += PDATA(nudge) ; xlabel[1] -= PDATA(nudge) ;
      ylabel[0] += PDATA(nudge) ; ylabel[1] -= PDATA(nudge) ;
      zlabel[0] += PDATA(nudge) ; zlabel[1] -= PDATA(nudge) ;
    }
#endif

  font(0) ;
  cmov2 (xlabel[0], xlabel[1]) ;
  charstr ("X") ;
  cmov2 (ylabel[0], ylabel[1]) ;
  charstr ("Y") ;
  cmov2 (zlabel[0], zlabel[1]) ;
  charstr ("Z") ;

  popmatrix() ;

  if (draw && PDATA(redrawmode) != tdmViewEchoMode)
    {
      /* copy rendered gnomon from back buffer to front buffer */
      readsource(SRC_BACK) ;
      frontbuffer(TRUE) ;
      backbuffer(FALSE) ;
      rectcopy (PDATA(illx), PDATA(illy), PDATA(iurx), PDATA(iury),
		PDATA(illx), PDATA(illy)) ;

      /* restore original buffer config from current tdmFrontBufferDraw */
      _dxf_BUFFER_RESTORE_CONFIG
	  (PORT_CTX, dummy, PDATA(buffermode), tdmFrontBufferDraw) ;
    }

  EXIT((""));
}