*** term/tgif.trm.ORG	Thu Oct 28 16:12:12 2004
--- term/tgif.trm	Fri Nov 26 22:26:40 2004
***************
*** 74,79 ****
--- 74,83 ----
  register_term(tgif)
  #endif
  
+ /* added by shige 11/26 2004 */
+ #define USE_LINEWIDTH
+ #define USE_MONO_MODE
+ 
  #ifdef TERM_PROTO
  TERM_PUBLIC void TGIF_options __PROTO((void));
  TERM_PUBLIC void TGIF_init __PROTO((void));
***************
*** 90,95 ****
--- 94,102 ----
  TERM_PUBLIC void TGIF_arrow __PROTO((unsigned int sx, unsigned int sy, unsigned int ex, unsigned int ey, int head));
  TERM_PUBLIC int TGIF_set_font __PROTO((const char *font));
  TERM_PUBLIC void TGIF_set_pointsize __PROTO((double size));
+ #ifdef USE_LINEWIDTH
+ TERM_PUBLIC void TGIF_set_linewidth __PROTO((double size));
+ #endif
  #ifdef PM3D
  TERM_PUBLIC int TGIF_make_palette (t_sm_palette *);
  /* TERM_PUBLIC void TGIF_previous_palette (void); */
***************
*** 161,166 ****
--- 168,179 ----
  static unsigned int uTgif_win_horiz, /* number of plots in x and  */ uTgif_win_verti;	/*      y direction [x,y]         */
  
  
+ #ifdef USE_LINEWIDTH
+ static double uActThick_factor;
+ #endif
+ #ifdef USE_MONO_MODE
+ static TBOOLEAN TgifUseColor = TRUE;
+ #endif
  
  static char sActColor[TGIF_STRLEN_MAX];		/* current color         */
  static unsigned int uDefaultFontSize;	/* default font size         */
***************
*** 267,272 ****
--- 280,298 ----
  
  /*}}}  */
  
+ #ifdef USE_MONO_MODE
+     if (!END_OF_COMMAND) {
+ 	if (almost_equals(c_token, "m$onochrome")) {
+ 	    TgifUseColor = FALSE;
+ 	    c_token++;
+ 	} else if (almost_equals(c_token, "c$olor") 
+ 		   || almost_equals(c_token, "c$olour") ) {
+ 	    TgifUseColor = TRUE;
+ 	    c_token++;
+ 	}
+     }
+ #endif
+ 
      if (!END_OF_COMMAND) {
  	if (almost_equals(c_token, "p$ortrait")) {
  	    TgifPortrait = TRUE;
***************
*** 368,374 ****
--- 394,405 ----
  
  /*}}}  */
  
+ #ifndef USE_MONO_MODE
      sprintf(term_options, "%s [%u,%u] %s \"%s\" %u",
+ #else
+     sprintf(term_options, "%s %s [%u,%u] %s \"%s\" %u",
+ 	    TgifUseColor ? "color" : "monochrome",
+ #endif
  	    TgifPortrait ? "portrait" : "landscape",
  	    uTgif_win_horiz, uTgif_win_verti,
  	    TgifSolid ? "solid" : "dashed",
***************
*** 461,467 ****
--- 492,506 ----
      uActThick = 1;
      uActStyle = 0;
      uActJust = LEFT;
+ #ifndef USE_MONO_MODE
      strcpy(sActColor, psColors[0]);
+ #else
+     if(TgifUseColor == FALSE) strcpy(sActColor,"black");
+     else strcpy(sActColor, psColors[0]);
+ #endif
+ #ifdef USE_LINEWIDTH
+     uActThick_factor = 1.0;
+ #endif
  
  
  }				/* TGIF_graphics */
***************
*** 507,514 ****
--- 546,562 ----
      else
  	ult = linetype + 2;
  
+ #ifndef USE_MONO_MODE
      strcpy(sActColor, psColors[ult]);
+ #else
+     if(TgifUseColor == FALSE) strcpy(sActColor,"black");
+     else strcpy(sActColor, psColors[ult]);
+ #endif
+ #ifndef USE_LINEWIDTH
      uActThick = uLineThick[ult];
+ #else
+     uActThick = uActThick_factor * uLineThick[ult];
+ #endif
      if (!TgifSolid)
  	uActStyle = uLineStyle[ult];
      else {
***************
*** 1481,1486 ****
--- 1529,1542 ----
      uActPointSize = size < 0. ? 1. : size;
  }
  
+ #ifdef USE_LINEWIDTH
+ TERM_PUBLIC void
+ TGIF_set_linewidth(double size)
+ {
+     uActThick_factor = size < 0. ? 1. : size;
+ }
+ #endif
+ 
  /*}}}  */
  /***************************************************************************/
  TERM_PUBLIC int
***************
*** 1509,1514 ****
--- 1565,1585 ----
      TGIF_flush_poly(); /* Clean up current data */
  
      if (TGIF_palette_set == FALSE) {
+ #ifdef USE_MONO_MODE
+ 	if (TgifUseColor == FALSE 
+ 	    || sm_palette.colorMode == SMPAL_COLOR_MODE_GRAY) {
+             /* Gray palette */
+ 	    if (TgifUseColor == FALSE 
+ 		&& sm_palette.colorMode == SMPAL_COLOR_MODE_RGB){
+ 		fprintf(stderr, "Monochrome Tgif file: ");
+ 		fprintf(stderr, "using gray palette instead of color\n");
+ 	    }
+             for (i = 0; i < sm_palette.colors; i++) {
+                 int j = (int)(i * 255.0 / (sm_palette.colors-1) + 0.5);
+                 sprintf(TGIF_colours[i],"#%.2x%.2x%.2x",j,j,j);
+             }
+ 	} else {
+ #endif    
  	/* Create new palette */
  	for (i = 0; i < sm_palette.colors; i++) {
  	    sprintf(TGIF_colours[i],"#%.2x%.2x%.2x",
***************
*** 1516,1521 ****
--- 1587,1595 ----
  		(int)( palette->color[i].g * 255 + 0.5 ),
  		(int)( palette->color[i].b * 255 + 0.5 ) );
  	}
+ #ifdef USE_MONO_MODE
+ 	}
+ #endif
  	TGIF_palette_set = TRUE;
      } else {
  	fprintf(stderr, "Attempt to set palette twice\n");
***************
*** 1578,1584 ****
--- 1652,1662 ----
      TGIF_text, null_scale, TGIF_graphics, TGIF_move, TGIF_vector,
      TGIF_linetype, TGIF_put_text, TGIF_text_angle,
      TGIF_justify_text, TGIF_point, TGIF_arrow, TGIF_set_font,
+ #ifndef USE_LINEWIDTH
      TGIF_set_pointsize, TERM_CAN_MULTIPLOT, 0, 0, 0, 0
+ #else
+     TGIF_set_pointsize, TERM_CAN_MULTIPLOT, 0, 0, 0, TGIF_set_linewidth
+ #endif
  #ifdef USE_MOUSE
      ,0, 0, 0, 0, 0 /* no mouse support for the tgif terminal */
  #endif
