|
From: Shigeharu T. <sh...@ie...> - 2004-11-27 08:52:55
|
shige 11/27 2004 ---------------- I tested the following simple patch for linewidth and monochrome mode for term/tgif.trm (rev. 1.28). It seems to work fine. ----- From here ----- *** term/tgif.trm.ORG Thu Oct 28 16:12:12 2004 --- term/tgif.trm Sat Nov 27 17:49:55 2004 *************** *** 74,79 **** --- 74,82 ---- register_term(tgif) #endif + #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 **** --- 93,101 ---- 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 **** --- 167,178 ---- 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 **** --- 279,297 ---- /*}}} */ + #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 **** --- 393,404 ---- /*}}} */ + #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 **** --- 491,505 ---- 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 **** --- 545,561 ---- 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]+0.5; + #endif if (!TgifSolid) uActStyle = uLineStyle[ult]; else { *************** *** 1481,1486 **** --- 1528,1541 ---- 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 **** --- 1564,1584 ---- 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 **** --- 1586,1594 ---- (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 **** --- 1651,1661 ---- 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 ----- To here ----- +========================================================+ Shigeharu TAKENO NIigata Institute of Technology kashiwazaki,Niigata 945-1195 JAPAN sh...@ie... TEL(&FAX): +81-257-22-8161 +========================================================+ |