From 045a1c6b9080400cdf2e147770d70e5231b2df02 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Wed, 31 Oct 2001 08:34:19 +0000
Subject: [PATCH] post 2d polish (2nd coating)

---
 Common/DefaultOptions.h       |   2 +
 Common/Options.cpp            |  16 ++++-
 Common/Options.h              |   1 +
 Common/Views.cpp              |  34 ++++++---
 Common/Views.h                |   4 +-
 DataStr/List.cpp              |  18 +++--
 Fltk/Callbacks.cpp            |  10 ++-
 Fltk/GUI.cpp                  |  37 +++++++---
 Fltk/GUI.h                    |   2 +-
 Graphics/Axes.cpp             |  10 +--
 Graphics/Graph2D.cpp          | 130 +++++++++++++++++++++++++---------
 Graphics/Post.cpp             |   4 +-
 Graphics/Scale.cpp            |   5 +-
 benchmarks/2d/transfinite.geo |   2 +-
 benchmarks/misc/charts.geo    |   5 +-
 doc/FORMATS                   |  55 ++++++++++----
 doc/VERSIONS                  |   6 +-
 17 files changed, 241 insertions(+), 100 deletions(-)

diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h
index 18a9ba7ecf..95d199c708 100644
--- a/Common/DefaultOptions.h
+++ b/Common/DefaultOptions.h
@@ -481,6 +481,8 @@ StringXNumber ViewOptions_Number[] = {
     "Saturate the view values to custom min and max (1=true, 0=false)" },
   { F|O, "GraphType" , opt_view_graph_type , DRAW_POST_3D ,
     "Graph type (1=3D, 2=2D-space, 3=2D-time)" },
+  { F|O, "GraphGrid" , opt_view_graph_grid , 1 ,
+    "Grid mode for 2D graphs (0=none, 1=simple, 2=frame, 3=grid)" },
   { F|O, "GraphPositionX" , opt_view_graph_position0 , 100. , 
     "Horizontal position (in pixels) of the upper left corner of a 2D graph" }, 
   { F|O, "GraphPositionY" , opt_view_graph_position1 , 100. , 
diff --git a/Common/Options.cpp b/Common/Options.cpp
index 01aa916de9..705cb5c7bf 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -1,4 +1,4 @@
-// $Id: Options.cpp,v 1.53 2001-10-30 14:27:47 geuzaine Exp $
+// $Id: Options.cpp,v 1.54 2001-10-31 08:34:18 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -1927,6 +1927,20 @@ double opt_view_graph_size1(OPT_ARGS_NUM){
   return v->GraphSize[1];
 }
 
+double opt_view_graph_grid(OPT_ARGS_NUM){
+  GET_VIEW(0.) ;
+  if(action & GMSH_SET){
+    v->GraphGrid = (int)val;
+    v->Changed = 1;
+  }
+#ifdef _FLTK
+  if(WID && (action & GMSH_GUI) && (num == WID->view_number)){
+    WID->view_value[24]->value(v->GraphGrid);
+  }
+#endif
+  return v->GraphGrid;
+}
+
 double opt_view_nb_iso(OPT_ARGS_NUM){
   GET_VIEW(0.) ;
   if(action & GMSH_SET){
diff --git a/Common/Options.h b/Common/Options.h
index 664b59dfb0..d24f062161 100644
--- a/Common/Options.h
+++ b/Common/Options.h
@@ -222,6 +222,7 @@ double opt_view_visible(OPT_ARGS_NUM);
 double opt_view_intervals_type(OPT_ARGS_NUM);
 double opt_view_saturate_values(OPT_ARGS_NUM);
 double opt_view_graph_type(OPT_ARGS_NUM);
+double opt_view_graph_grid(OPT_ARGS_NUM);
 double opt_view_graph_position0(OPT_ARGS_NUM);
 double opt_view_graph_position1(OPT_ARGS_NUM);
 double opt_view_graph_size0(OPT_ARGS_NUM);
diff --git a/Common/Views.cpp b/Common/Views.cpp
index 3a962d616d..1fb9f75c28 100644
--- a/Common/Views.cpp
+++ b/Common/Views.cpp
@@ -1,4 +1,4 @@
-// $Id: Views.cpp,v 1.57 2001-10-30 16:02:29 geuzaine Exp $
+// $Id: Views.cpp,v 1.58 2001-10-31 08:34:18 geuzaine Exp $
 
 #include <set>
 #include "Gmsh.h"
@@ -98,6 +98,7 @@ Post_View * BeginView(int allocate){
   v->Links = 0;
   v->DuplicateOf = 0;
   v->ScalarOnly = 1;
+  v->TextOnly = 1;
   v->normals = NULL;
   v->Min = INFINITY;
   v->Max = -INFINITY;
@@ -134,6 +135,8 @@ void Stat_ScalarSimplex(Post_View *v, int nbnod, int N,
     if(Z[i] < v->BBox[4]) v->BBox[4] = Z[i] ;
     if(Z[i] > v->BBox[5]) v->BBox[5] = Z[i] ;
   }
+
+  v->TextOnly = 0;
 }
 
 void Stat_VectorSimplex(Post_View *v, int nbnod, int N, 
@@ -166,6 +169,7 @@ void Stat_VectorSimplex(Post_View *v, int nbnod, int N,
   }
 
   v->ScalarOnly = 0;
+  v->TextOnly = 0;
 }
 
 void Stat_TensorSimplex(Post_View *v, int nbnod, int N, 
@@ -405,6 +409,7 @@ void CopyViewOptions(Post_View *src, Post_View *dest){
   dest->IntervalsType = src->IntervalsType;
   dest->SaturateValues = src->SaturateValues;
   dest->GraphType = src->GraphType;
+  dest->GraphGrid = src->GraphGrid;
   dest->GraphPosition[0] = src->GraphPosition[0];
   dest->GraphPosition[1] = src->GraphPosition[1];
   dest->GraphSize[0] = src->GraphSize[0];
@@ -424,6 +429,7 @@ void CopyViewOptions(Post_View *src, Post_View *dest){
   dest->DrawScalars = src->DrawScalars;
   dest->DrawVectors = src->DrawVectors;
   dest->DrawTensors = src->DrawTensors;
+  dest->DrawStrings = src->DrawStrings;
   dest->TransparentScale = src->TransparentScale;
   dest->ScaleType = src->ScaleType;
   dest->RangeType = src->RangeType;
@@ -471,7 +477,7 @@ void Print_ColorTable(int num, char *prefix, FILE *file){
 
 void Read_View(FILE *file, char *filename){
   char   str[256], name[256];
-  int    nb, format, size, testone, swap, t2l, t3l;
+  int    i, nb, format, size, testone, swap, t2l, t3l;
   double version;
   Post_View *v;
 
@@ -536,6 +542,8 @@ void Read_View(FILE *file, char *filename){
 	v->NbT2 = t2l = v->NbT3 = t3l = 0;
       }
 
+      for(i=0;i<(int)strlen(name);i++) if(name[i]=='^') name[i]=' '; 
+
       swap = 0 ;
       if(format == LIST_FORMAT_BINARY){
 	fread(&testone, sizeof(int), 1, file);
@@ -635,8 +643,12 @@ void Read_View(FILE *file, char *filename){
 /*  W r i t e _ V i e w                                                     */
 /* ------------------------------------------------------------------------ */
 
+// Ajouter un entier par simplexe (num de region)?
+// Format liste de noeuds + liste de simplexes ?
+
 void Write_View(int Flag_BIN, Post_View *v, char *filename){
   FILE *file;
+  char name[256];
   int i, f, One=1;
 
   if(filename){
@@ -648,17 +660,19 @@ void Write_View(int Flag_BIN, Post_View *v, char *filename){
   }
   else
     file = stdout;
- 
+
   fprintf(file, "$PostFormat /* Gmsh 1.1, %s */\n", Flag_BIN ? "binary" : "ascii") ;
   fprintf(file, "1.1 %d %d\n", Flag_BIN, (int)sizeof(double)) ;
   fprintf(file, "$EndPostFormat\n") ;
-  for(i=0;i<(int)strlen(v->Name);i++) if(v->Name[i]==' ') v->Name[i]='_'; 
-  // -> Il faudra changer le format de post pour autoriser les blancs.
-  // On ajoutera aussi un entier par simplexe (num de region).
-  // Devrait-on passer a un format liste de noeuds + liste de
-  // simplexes ?
+
+  for(i=0;i<(int)strlen(v->Name);i++){
+    if(v->Name[i]==' ') name[i]='^'; 
+    else name[i]=v->Name[i];
+  }
+  name[i]='\0';
+
   fprintf(file, "$View /* %s */\n", v->Name);
-  fprintf(file, "%s ", v->Name);
+  fprintf(file, "%s ", name);
   fprintf(file, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", 
 	  List_Nbr(v->Time),
 	  v->NbSP, v->NbVP, v->NbTP, v->NbSL, v->NbVL, v->NbTL, 
@@ -679,7 +693,7 @@ void Write_View(int Flag_BIN, Post_View *v, char *filename){
   List_WriteToFile(v->VS, file, f); List_WriteToFile(v->TS, file, f);
   List_WriteToFile(v->T2D, file, f); List_WriteToFile(v->T2C, file, f);
   List_WriteToFile(v->T3D, file, f); List_WriteToFile(v->T3C, file, f);
-  if(Flag_BIN) fprintf(file, "\n");
+  fprintf(file, "\n");
   fprintf(file, "$EndView\n");
 
   if(filename){
diff --git a/Common/Views.h b/Common/Views.h
index 6045dd15d9..f20a9711a7 100644
--- a/Common/Views.h
+++ b/Common/Views.h
@@ -13,7 +13,7 @@ class Post_View{
 
   // the data
   int datasize; // size(double) or sizeof(float)
-  int NbTimeStep, ScalarOnly;
+  int NbTimeStep, ScalarOnly, TextOnly;
   double Min, Max, BBox[6];
   List_T *Time;
   int NbSP, NbVP, NbTP;
@@ -43,7 +43,7 @@ class Post_View{
   int DrawScalars, DrawVectors, DrawTensors;
   int Boundary, PointSize, LineWidth;
   ColorTable CT;
-  int GraphType, GraphPosition[2], GraphSize[2];
+  int GraphType, GraphPosition[2], GraphSize[2], GraphGrid;
 
   // dynamic
   double (*GVFI) (double min, double max, int nb, int index);
diff --git a/DataStr/List.cpp b/DataStr/List.cpp
index 754e2a3369..03b127f7cf 100644
--- a/DataStr/List.cpp
+++ b/DataStr/List.cpp
@@ -1,4 +1,4 @@
-// $Id: List.cpp,v 1.17 2001-10-30 16:02:29 geuzaine Exp $
+// $Id: List.cpp,v 1.18 2001-10-31 08:34:19 geuzaine Exp $
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -383,13 +383,12 @@ List_T *List_CreateFromFile(int n, int size, FILE *file, int format, int swap){
       for(i=0;i<n;i++) fscanf(file, "%f", (float*)&liste->array[i*size]) ;
     else if(size == sizeof(int))
       for(i=0;i<n;i++) fscanf(file, "%d", (int*)&liste->array[i*size]) ;
-    /*
-    else if(size == sizeof(char))
+    else if(size == sizeof(char)){
       for(i=0;i<n;i++){
 	fscanf(file, "%c", (char*)&liste->array[i*size]) ;
 	if(liste->array[i*size]=='^') liste->array[i*size]='\0';
       }
-    */
+    }
     else{
       Msg(GERROR, "Bad type of data to create list from (size = %d)", size);
       return NULL;
@@ -414,23 +413,22 @@ void List_WriteToFile(List_T *liste, FILE *file, int format){
   switch(format){
   case LIST_FORMAT_ASCII :
     if(liste->size == sizeof(double))
-      for(i=0;i<n;i++) fprintf(file, "%g ", *((double*)&liste->array[i*liste->size])) ;
+      for(i=0;i<n;i++) fprintf(file, " %g", *((double*)&liste->array[i*liste->size])) ;
     else if(liste->size == sizeof(float))
-      for(i=0;i<n;i++) fprintf(file, "%g ", *((float*)&liste->array[i*liste->size])) ;
+      for(i=0;i<n;i++) fprintf(file, " %g", *((float*)&liste->array[i*liste->size])) ;
     else if(liste->size == sizeof(int))
-      for(i=0;i<n;i++) fprintf(file, "%d ", *((int*)&liste->array[i*liste->size])) ;
-    /*
+      for(i=0;i<n;i++) fprintf(file, " %d", *((int*)&liste->array[i*liste->size])) ;
     else if(liste->size == sizeof(char))
       for(i=0;i<n;i++){
 	if(*((char*)&liste->array[i*liste->size]) == '\0')
 	  fprintf(file, "^") ;
+	else if(*((char*)&liste->array[i*liste->size]) == '^')
+	  fprintf(file, "_") ;//we don't allow '^' as a valid character
 	else
 	  fprintf(file, "%c", *((char*)&liste->array[i*liste->size])) ;
       }
-    */
     else
       Msg(GERROR, "Bad type of data to write list to file (size = %d)", liste->size);
-    fprintf(file, "\n");
     break;
   case LIST_FORMAT_BINARY :
     fwrite(liste->array, liste->size, n, file);
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index c0e0715be3..3b72a4aa0b 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.89 2001-10-30 14:27:47 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.90 2001-10-31 08:34:19 geuzaine Exp $
 
 #include <sys/types.h>
 #include <signal.h>
@@ -1672,7 +1672,10 @@ static void _duplicate_view(int num, int options){
   v2->NbSS = v1->NbSS; v2->SS = v1->SS; 
   v2->NbVS = v1->NbVS; v2->VS = v1->VS; 
   v2->NbTS = v1->NbTS; v2->TS = v1->TS;
+  v2->NbT2 = v1->NbT2; v2->T2D = v1->T2D; v2->T2C = v1->T2C;
+  v2->NbT3 = v1->NbT3; v2->T3D = v1->T3D; v2->T3C = v1->T3C;
   v2->ScalarOnly  = v1->ScalarOnly;
+  v2->TextOnly    = v1->TextOnly;
   v2->Min         = v1->Min;       
   v2->Max         = v1->Max;      
   v2->NbTimeStep  = v1->NbTimeStep;
@@ -1690,7 +1693,7 @@ void view_duplicate_with_options_cb(CALLBACK_ARGS){
 
 void view_applybgmesh_cb(CALLBACK_ARGS){
   Post_View *v = (Post_View*)List_Pointer(CTX.post.list,(int)data);
-  if(!v->ScalarOnly){
+  if(!v->ScalarOnly || v->TextOnly){
     Msg(GERROR, "Background mesh generation impossible with non-scalar view");
     return;
   }
@@ -1934,6 +1937,9 @@ void view_options_ok_cb(CALLBACK_ARGS){
       if(force || WID->view_value[23]->changed())
 	opt_view_graph_size1(i,GMSH_SET,WID->view_value[23]->value());
 
+      if(force || WID->view_value[24]->changed())
+	opt_view_graph_grid(i,GMSH_SET,WID->view_value[24]->value());
+
       // view_inputs
 
       if(force || WID->view_input[0]->changed())      
diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp
index 175dd7d12c..c37fd0faa9 100644
--- a/Fltk/GUI.cpp
+++ b/Fltk/GUI.cpp
@@ -1,4 +1,4 @@
-// $Id: GUI.cpp,v 1.123 2001-10-30 14:33:52 geuzaine Exp $
+// $Id: GUI.cpp,v 1.124 2001-10-31 08:34:19 geuzaine Exp $
 
 // To make the interface as visually consistent as possible, please:
 // - use the BH, BW, WB, IW values for button heights/widths, window borders, etc.
@@ -456,7 +456,7 @@ int GUI::global_shortcuts(int event){
   else if(Fl::test_shortcut(FL_ALT+'n')){
     for(i=0 ; i<List_Nbr(CTX.post.list) ; i++)
       if(opt_view_visible(i,GMSH_GET,0))
-	opt_view_draw_strings(i, GMSH_SET|GMSH_GUI,!opt_view_draw_strings(0,GMSH_GET,0));
+	opt_view_draw_strings(i, GMSH_SET|GMSH_GUI,!opt_view_draw_strings(i,GMSH_GET,0));
     redraw_opengl();
     return 1;
   }
@@ -2084,9 +2084,9 @@ void GUI::create_view_options_window(int num){
       }
       // 3D
       { 
-	Fl_Group *o = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "3D");
-	o->labelsize(CTX.fontsize);
-        o->hide();
+	view_3d = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "3D");
+	view_3d->labelsize(CTX.fontsize);
+        view_3d->hide();
 
         view_butt[10] = new Fl_Check_Button(width/2, 2*WB+1*BH, BW, BH, "Show elements");
 	view_butt[11] = new Fl_Check_Button(width/2, 2*WB+2*BH, BW, BH, "Enable Lighting");
@@ -2133,7 +2133,7 @@ void GUI::create_view_options_window(int num){
 	  view_butt[i]->callback(set_changed_cb, 0);
 	}
 
-        o->end();
+        view_3d->end();
       }
       // 2D
       { 
@@ -2145,7 +2145,11 @@ void GUI::create_view_options_window(int num){
 	view_value[21] = new Fl_Value_Input(2*WB, 2*WB+ 2*BH, IW, BH, "Y position");
 	view_value[22] = new Fl_Value_Input(2*WB, 2*WB+ 3*BH, IW, BH, "Width");
 	view_value[23] = new Fl_Value_Input(2*WB, 2*WB+ 4*BH, IW, BH, "Height");
-	for(i=20 ; i<=23 ; i++){
+        view_value[24] = new Fl_Value_Input(2*WB, 2*WB+ 5*BH, IW, BH, "Grid mode");
+	view_value[24]->minimum(0.); 
+	view_value[24]->step(1); 
+	view_value[24]->maximum(3); 
+	for(i=20 ; i<=24 ; i++){
 	  view_value[i]->labelsize(CTX.fontsize);
 	  view_value[i]->textsize(CTX.fontsize);
 	  view_value[i]->type(FL_HORIZONTAL);
@@ -2157,9 +2161,9 @@ void GUI::create_view_options_window(int num){
       }
       // Range
       { 
-	Fl_Group *o = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Range");
-	o->labelsize(CTX.fontsize);
-	o->hide();
+	view_range = new Fl_Group(WB, WB+BH, width-2*WB, height-3*WB-2*BH, "Range");
+	view_range->labelsize(CTX.fontsize);
+	view_range->hide();
 
 	view_value[30] = new Fl_Value_Input(2*WB, 2*WB+1*BH, IW, BH, "Intervals");
 	view_value[30]->labelsize(CTX.fontsize);
@@ -2224,7 +2228,7 @@ void GUI::create_view_options_window(int num){
 	view_butt[38]->selection_color(FL_YELLOW);
 	view_butt[38]->callback(set_changed_cb, 0);
 
-	o->end();
+	view_range->end();
       }
       // Offset and Raise
       { 
@@ -2382,6 +2386,16 @@ void GUI::update_view_window(int num){
   opt_view_transparent_scale(num, GMSH_GUI, 0);
 
   //3D
+  if(v->TextOnly){
+    view_3d->deactivate();
+    view_range->deactivate();
+    view_butt[1]->deactivate();
+  }
+  else{
+    view_3d->activate();
+    view_range->activate();
+    view_butt[1]->activate();
+  }
   opt_view_show_element(num, GMSH_GUI, 0);
   opt_view_light(num, GMSH_GUI, 0);
   opt_view_smooth_normals(num, GMSH_GUI, 0);
@@ -2411,6 +2425,7 @@ void GUI::update_view_window(int num){
   opt_view_graph_position1(num, GMSH_GUI, 0);
   opt_view_graph_size0(num, GMSH_GUI, 0);
   opt_view_graph_size1(num, GMSH_GUI, 0);
+  opt_view_graph_grid(num, GMSH_GUI, 0);
 
   // range
   opt_view_nb_iso(num, GMSH_GUI, 0);
diff --git a/Fltk/GUI.h b/Fltk/GUI.h
index 1098df22ad..5129f0f294 100644
--- a/Fltk/GUI.h
+++ b/Fltk/GUI.h
@@ -159,7 +159,7 @@ public:
   // view options window
   int init_view_window, view_number ;
   Fl_Window        *view_window ;
-  Fl_Group         *view_2d, *view_timestep, *view_vector ;
+  Fl_Group         *view_2d, *view_3d, *view_range, *view_timestep, *view_vector ;
 #define VIEW_OPT_BUTT 100
   Fl_Check_Button  *view_butt[VIEW_OPT_BUTT] ;
   Fl_Value_Input   *view_value[VIEW_OPT_BUTT] ;
diff --git a/Graphics/Axes.cpp b/Graphics/Axes.cpp
index 5e5d5c4ec6..e152fff5e6 100644
--- a/Graphics/Axes.cpp
+++ b/Graphics/Axes.cpp
@@ -1,4 +1,4 @@
-// $Id: Axes.cpp,v 1.9 2001-10-30 08:18:50 geuzaine Exp $
+// $Id: Axes.cpp,v 1.10 2001-10-31 08:34:19 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -23,8 +23,8 @@ void Draw_Axes (double s) {
   b = .1 * s;
   c = 0.666 * b;
 
-  glLineWidth(CTX.line_width); 
-  gl2psLineWidth(CTX.line_width*CTX.print.eps_line_width_factor);
+  glLineWidth(1); 
+  gl2psLineWidth(1*CTX.print.eps_line_width_factor);
   glColor4ubv((GLubyte*)&CTX.color.axes);
 
   glBegin(GL_LINES);
@@ -117,8 +117,8 @@ void Draw_SmallAxes(void){
   yx = l*CTX.rot[1][0] ; yy = l*CTX.rot[1][1] ;
   zx = l*CTX.rot[2][0] ; zy = l*CTX.rot[2][1] ;
 
-  glLineWidth(CTX.line_width); 
-  gl2psLineWidth(CTX.line_width*CTX.print.eps_line_width_factor);
+  glLineWidth(1); 
+  gl2psLineWidth(1*CTX.print.eps_line_width_factor);
   glColor4ubv((GLubyte*)&CTX.color.small_axes);
 
   glBegin(GL_LINES);
diff --git a/Graphics/Graph2D.cpp b/Graphics/Graph2D.cpp
index 3f4329654d..d894961bf0 100644
--- a/Graphics/Graph2D.cpp
+++ b/Graphics/Graph2D.cpp
@@ -1,4 +1,4 @@
-// $Id: Graph2D.cpp,v 1.7 2001-10-30 14:27:47 geuzaine Exp $
+// $Id: Graph2D.cpp,v 1.8 2001-10-31 08:34:19 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -83,64 +83,124 @@ static void Draw_Graph2D(Post_View *v){
 
   // The axes + labels
   
-  if(v->ShowScale){
-    glPointSize(CTX.point_size); 
-    gl2psPointSize(CTX.point_size * CTX.print.eps_point_size_factor);
-
-    glLineWidth(CTX.line_width); 
-    gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor);
+  glPointSize(CTX.point_size); 
+  gl2psPointSize(CTX.point_size * CTX.print.eps_point_size_factor);
 
-    // 2 axes
+  glLineWidth(CTX.line_width); 
+  gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor);
+  
+  // 2 axes
+  if(v->GraphGrid){
     glColor4ubv((GLubyte*)&CTX.color.fg);
     glBegin(GL_LINE_STRIP);
     glVertex2d(xtop,ytop);
     glVertex2d(xtop,ytop-v->GraphSize[1]);
     glVertex2d(xtop+v->GraphSize[0],ybot);
+    if(v->GraphGrid>1){
+      glVertex2d(xtop+v->GraphSize[0],ytop);
+      glVertex2d(xtop,ytop);
+    }
     glEnd();
-
-    // y tics + labels
-    if(v->NbIso * font_h > v->GraphSize[1])
-      nb = 1;
-    else
-      nb = v->NbIso;
-    dy = v->GraphSize[1]/(double)nb;
-    dv = (ValMax-ValMin)/(double)nb;
-    for(i=0; i<nb+1; i++){
+  }
+  
+  // y tics + labels
+  if(v->NbIso * font_h > v->GraphSize[1])
+    nb = 1;
+  else
+    nb = v->NbIso;
+  dy = v->GraphSize[1]/(double)nb;
+  dv = (ValMax-ValMin)/(double)nb;
+  for(i=0; i<nb+1; i++){
+    if(v->GraphGrid>0 && i!=0 && i!=nb){
+      glColor4ubv((GLubyte*)&CTX.color.fg);
       glBegin(GL_LINES);
       glVertex2d(xtop,ytop-i*dy);
       glVertex2d(xtop+TIC,ytop-i*dy);
+      if(v->GraphGrid>1){
+	glVertex2d(xtop+v->GraphSize[0]-TIC,ytop-i*dy);
+	glVertex2d(xtop+v->GraphSize[0],ytop-i*dy);
+      }
       glEnd();
+      if(v->GraphGrid>2){
+	glEnable(GL_LINE_STIPPLE);
+	glLineStipple(1,0x1111);
+	gl2psEnable(GL2PS_LINE_STIPPLE);
+	glLineWidth(1); 
+	gl2psLineWidth(1 * CTX.print.eps_line_width_factor);
+	glBegin(GL_LINES);
+	glVertex2d(xtop,ytop-i*dy);
+	glVertex2d(xtop+v->GraphSize[0],ytop-i*dy);
+	glEnd();
+	glDisable(GL_LINE_STIPPLE);
+	gl2psDisable(GL2PS_LINE_STIPPLE);
+	glLineWidth(CTX.line_width); 
+	gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor);
+      }
+    }
+    if(v->ShowScale){
+      glColor4ubv((GLubyte*)&CTX.color.text);
       sprintf(label, v->Format, (i==nb)?ValMin:(ValMax-i*dv));
-      glRasterPos2d(xtop-gl_width(label)-TIC,ytop-i*dy-font_a/3.);
+      if(CTX.stream == TO_FILE)
+	glRasterPos2d(xtop-gl_width(label)-3*TIC,ytop-i*dy-font_a/3.);
+      else
+	glRasterPos2d(xtop-gl_width(label)-TIC,ytop-i*dy-font_a/3.);
       Draw_String(label);
     }
-
+  }
+  
+  if(v->ShowScale){
+    glColor4ubv((GLubyte*)&CTX.color.text);
     if(v->GraphType==DRAW_POST_2D_SPACE && List_Nbr(v->Time)>1 && v->ShowTime)
       sprintf(label, "%s (%g)", v->Name, *(double*)List_Pointer(v->Time,v->TimeStep));
     else
       sprintf(label, "%s", v->Name);
     glRasterPos2d(xtop-gl_width(label)/2.,ytop+1.5*font_h);
     Draw_String(label);
+  }
 
+  // x tics + labels
+  if(v->GraphType==DRAW_POST_2D_SPACE)
+    nb = v->NbSP;
+  else
+    nb = v->NbTimeStep;
+  if(nb == 1) nb=0;
+  sprintf(label, v->Format, 9.999);
+  if(nb*gl_width(label) > v->GraphSize[0])
+    nb = 2;
+  dx = v->GraphSize[0]/(double)(nb-1);
+  double dist=0., p1[3]={0.,0.,0.}, p2[3];
+  j=0;
 
-    // x tics + labels
-    if(v->GraphType==DRAW_POST_2D_SPACE)
-      nb = v->NbSP;
-    else
-      nb = v->NbTimeStep;
-    if(nb == 1) nb=0;
-    sprintf(label, v->Format, 9.999);
-    if(nb*gl_width(label) > v->GraphSize[0])
-      nb = 2;
-    dx = v->GraphSize[0]/(double)(nb-1);
-    double dist=0., p1[3]={0.,0.,0.}, p2[3];
-    j=0;
-
-    for(i=0; i<nb; i++){
+  for(i=0; i<nb; i++){
+    if(v->GraphGrid>0 && i!=0 && i!=nb-1){
+      glColor4ubv((GLubyte*)&CTX.color.fg);
       glBegin(GL_LINES);
       glVertex2d(xtop+i*dx,ybot);
       glVertex2d(xtop+i*dx,ybot+TIC);
+      if(v->GraphGrid>1){
+	glVertex2d(xtop+i*dx,ytop);
+	glVertex2d(xtop+i*dx,ytop-TIC);
+      }
       glEnd();
+      if(v->GraphGrid>2){
+	glEnable(GL_LINE_STIPPLE);
+	glLineStipple(1,0x1111);
+	gl2psEnable(GL2PS_LINE_STIPPLE);
+	glLineWidth(1); 
+	gl2psLineWidth(1 * CTX.print.eps_line_width_factor);
+	glBegin(GL_LINES);
+	glVertex2d(xtop+i*dx,ytop);
+	glVertex2d(xtop+i*dx,ybot);
+	glEnd();
+	glDisable(GL_LINE_STIPPLE);
+	gl2psDisable(GL2PS_LINE_STIPPLE);
+	glLineWidth(CTX.line_width); 
+	gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor);
+      }
+    }
+
+    if(v->ShowScale){
+      glColor4ubv((GLubyte*)&CTX.color.text);
       if(v->GraphType==DRAW_POST_2D_SPACE){
 	for(k=0;k<3;k++){
 	  List_Read(v->SP,j+k,&p2[k]);
@@ -254,7 +314,9 @@ void Draw_Text2D3D(int dim, int timestep, int nb, List_T *td, List_T *tc){
     d2 = (double*)List_Pointer_Test(td, (j+1)*nbd);
     if(dim==2){
       x = d1[0];
+      if(x<0) x = CTX.viewport[2] + x;
       y = CTX.viewport[3]-d1[1];
+      if(d1[1]<0) y = -d1[1];
       z = 0.;
       style = d1[2];
       index = (int)d1[3];
@@ -290,7 +352,7 @@ void Draw_Text2D(void){
 
   if(!CTX.post.list) return;
 
-  glColor4ubv((GLubyte*)&CTX.color.fg);
+  glColor4ubv((GLubyte*)&CTX.color.text);
 
   for(i=0;i<List_Nbr(CTX.post.list);i++){
     v = (Post_View*)List_Pointer(CTX.post.list,i);
diff --git a/Graphics/Post.cpp b/Graphics/Post.cpp
index 582a7df8cb..a072a3d983 100644
--- a/Graphics/Post.cpp
+++ b/Graphics/Post.cpp
@@ -1,4 +1,4 @@
-// $Id: Post.cpp,v 1.27 2001-10-30 14:27:47 geuzaine Exp $
+// $Id: Post.cpp,v 1.28 2001-10-31 08:34:19 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -424,7 +424,7 @@ void Draw_Post (void) {
 	}
 
 	if(v->DrawStrings){
-	  glColor4ubv((GLubyte*)&CTX.color.fg);
+	  glColor4ubv((GLubyte*)&CTX.color.text);
 	  Draw_Text2D3D(3, v->TimeStep, v->NbT3, v->T3D, v->T3C);
 	}
 
diff --git a/Graphics/Scale.cpp b/Graphics/Scale.cpp
index 07788345f9..ef68d26258 100644
--- a/Graphics/Scale.cpp
+++ b/Graphics/Scale.cpp
@@ -1,4 +1,4 @@
-// $Id: Scale.cpp,v 1.24 2001-10-30 08:18:50 geuzaine Exp $
+// $Id: Scale.cpp,v 1.25 2001-10-31 08:34:19 geuzaine Exp $
 
 #include "Gmsh.h"
 #include "GmshUI.h"
@@ -215,7 +215,8 @@ void Draw_Scales(void){
 
   for(i=0;i<List_Nbr(CTX.post.list);i++){
     v = (Post_View*)List_Pointer(CTX.post.list,i);
-    if(v->Visible && v->ShowScale && v->GraphType==DRAW_POST_3D) List_Add(todraw,&v);
+    if(v->Visible && v->ShowScale && v->GraphType==DRAW_POST_3D && !v->TextOnly) 
+      List_Add(todraw,&v);
   }
   
   if(!List_Nbr(todraw)){
diff --git a/benchmarks/2d/transfinite.geo b/benchmarks/2d/transfinite.geo
index a3a0e36fad..d093675f62 100644
--- a/benchmarks/2d/transfinite.geo
+++ b/benchmarks/2d/transfinite.geo
@@ -27,7 +27,7 @@ Plane Surface(10) = {9};
 Line Loop(11) = {2,3,4,1};
 Plane Surface(12) = {11,9};
 
-Transfinite Line {5:8} = 10 Using Progression 5;
+Transfinite Line {5:8} = 10 Using Progression 0.7;
 
 Transfinite Surface{10} = {1,3,4,2};
 Recombine Surface {10} = 30;
diff --git a/benchmarks/misc/charts.geo b/benchmarks/misc/charts.geo
index 93a46db888..f54af44a84 100644
--- a/benchmarks/misc/charts.geo
+++ b/benchmarks/misc/charts.geo
@@ -15,8 +15,9 @@ View "test" {
   SP(9,0,0){0   ,0.2+0  ,0.42+0  ,0.2+0  ,0.42+0  ,0.2+0  ,0.42+0  ,0.2+0  ,0.42+0   };
 };
 
-View[0].GraphType=2;
-View[0].Format="%.3g";
+View[PostProcessing.NbViews-1].GraphType=2;
+View[PostProcessing.NbViews-1].Format="%.3g";
+View[PostProcessing.NbViews-1].GraphGrid=3;
 
 /*
 View "annote" {
diff --git a/doc/FORMATS b/doc/FORMATS
index c8dc161d51..a5bbb186e8 100644
--- a/doc/FORMATS
+++ b/doc/FORMATS
@@ -1,7 +1,7 @@
-$Id: FORMATS,v 1.9 2001-08-31 07:08:47 geuzaine Exp $
+$Id: FORMATS,v 1.10 2001-10-31 08:34:19 geuzaine Exp $
 
-This document describes the mesh and post-processing file formats for
-Gmsh, version >= 1.0. 
+This document describes the version 1.1 of Gmsh's mesh and
+post-processing file formats
 
 (This document deals only with the import/export interfaces for
 Gmsh. The language driving the behaviour of Gmsh for defining
@@ -57,13 +57,13 @@ pairs).
     $PostFormat
     version-number file-type data-size
     $EndPostFormat
-
     $View
     view-name nb-time-steps
     nb-scalar-points nb-vector-points nb-tensor-points
     nb-scalar-lines nb-vector-lines nb-tensor-lines
     nb-scalar-triangles nb-vector-triangles nb-tensor-triangles
     nb-scalar-tetrahedra nb-vector-tetrahedra nb-tensor-tetrahedra
+    nb-text2d nb-text2d-chars nb-test3d nb-text3d-chars
     time-step-values
     scalar-point-value ...
     vector-point-value ...
@@ -77,10 +77,12 @@ pairs).
     scalar-tetrahedron-value ...
     vector-tetrahedron-value ...
     tensor-tetrahedron-value ...
+    text2d ... text2d-chars ...
+    text3d ... text3d-chars ...
     $endView
 
 version-number is a floating point number giving the version of
-Gmsh for which the file is destined (e.g. 1.0).
+the file format (e.g. 1.1).
 
 file-type is an integer equal to 0 in the ASCII file format.
 
@@ -94,6 +96,11 @@ nb-time-step is an integer giving the number of time steps in the view
 nb-scalar-points, nb-vector-points, etc. are integers giving the
 number of scalar points, vector points, etc. in the view.
 
+nb-text2d and nb-text3d are integers giving the number of 2D text
+strings and 3d text strings in the view. nb-text2d-chars and
+nb-text3d-chars are integers giving the total number of characters in
+the 2d and 3d strings.
+
 time-step-values is a list of nb-time-steps double precision numbers
 giving the value of the time (or any other variable) for which an
 evolution was saved.
@@ -102,8 +109,7 @@ scalar-point-value, vector-point-value, etc. are lists of double
 precision numbers giving the node coordinates and the values
 associated with the nodes of the nb-scalar-points, nb-vector-points,
 etc. for each time-step-value. For example, vector-triangle-value is
-defined as
-
+defined as:
     coord1-node1 coord1-node2 coord1-node3
     coord2-node1 coord2-node2 coord2-node3
     coord3-node1 coord3-node2 coord3-node3
@@ -115,6 +121,22 @@ defined as
     comp1-node3-time2 comp2-node3-time2 comp3-node3-time2
     ...
 
+text2d is a list of 4 double precision numbers:
+    coord1 coord2 style index
+where index gives the starting index of the correspinding 2d text
+string in text2d-chars.
+
+text2d-chars is a list of nb-text2d-chars chars. Substrings are
+separated with the '^' characted (which is a forbidden character in
+regular strings).
+
+text3d is a list of 5 double precision numbers:
+    coord1 coord2 coord3 style index
+where index gives the starting index of the correspinding 3d text
+string in text3d-chars.
+
+text3d-chars is a list of nb-text3d-chars chars. Substrings are
+separated with the '^' characted.
 
 Gmsh Binary Post-Processing File Format
 =======================================
@@ -124,7 +146,8 @@ format, except that:
 
 1) file-type equals 1.
 
-2) all lists of floating point numbers are written in binary format
+2) all lists of floating point numbers and characters are written in
+   binary format
 
 3) there is an additional integer, of value 1, written before
    time-step-values. This integer is used for detecting if the
@@ -137,21 +160,22 @@ file in binary format:
 int one = 1;
 
 fprintf(file, "$PostFormat\n");
-fprintf(file, "%g %d %d\n", 1.0, 1, sizeof(double));
+fprintf(file, "%g %d %d\n", 1.1, 1, sizeof(double));
 fprintf(file, "$EndPostFormat\n");
 
 fprintf(file, "$View\n");
-fprintf(file, "%s %d %d %d %d %d %d %d %d %d %d %d %d %d\n", 
+fprintf(file, "%s %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n", 
         view-name, nb-time-steps,
         nb-scalar-points, nb-vector-points, nb-tensor-points,
         nb-scalar-lines, nb-vector-lines, nb-tensor-lines,
         nb-scalar-triangles, nb-vector-triangles, nb-tensor-triangles,
-        nb-scalar-tetrahedra, nb-vector-tetrahedra, nb-tensor-tetrahedra);
+        nb-scalar-tetrahedra, nb-vector-tetrahedra, nb-tensor-tetrahedra,
+	nb-text2d, nb-text2d-chars, nb-text3d, nb-text3d-chars);
 fwrite(&one, sizeof(int), 1, file);
 fwrite(time-step-values, sizeof(double), nb-time-steps, file);
-fwrite(all-scalar-point-values, sizeof(double), all-scalar-points, file);
+fwrite(all-scalar-point-values, sizeof(double), ..., file);
 ...
-fprintf(file, "$EndView\n");
+fprintf(file, "\n$EndView\n");
 
 In this pseudo-code, all-scalar-point-values is the array of double
 precision numbers containing all the scalar-point-value lists, put one
@@ -174,7 +198,7 @@ following:
      ...
    };
 
-   12 base objects can be displayed:
+   14 base objects can be displayed:
 
                        type-of-element   list-of-coordinates    list-of-values
    --------------------------------------------------------------------------------
@@ -190,6 +214,8 @@ following:
    scalar tetrahedron  SS                12                     4  * nb-time-steps
    vector tetrahedron  VS                12                     12 * nb-time-steps
    tensor tetrahedron  TS                12                     36 * nb-time-steps
+   text 2d             T2                4                      arbitrary
+   text 3d             T3                5                      arbitrary
 
 Contrary to the ASCII post-processing file format, the coordinates are
 given by node, i.e. (coord1, coord2, coord3) for a point,
@@ -198,4 +224,3 @@ coord3-node2) for a line, (coord1-node1, coord2-node1, coord3-node1,
 coord1-node2, coord2-node2, coord3-node2, coord1-node3, coord2-node3,
 coord3-node3) for a triangle, etc. The values are given in the same
 order as for the ASCII post-processing file format.
-
diff --git a/doc/VERSIONS b/doc/VERSIONS
index 0b404c8d99..cc82ce5c6f 100644
--- a/doc/VERSIONS
+++ b/doc/VERSIONS
@@ -1,10 +1,12 @@
-$Date: 2001-10-29 17:14:50 $
+$Date: 2001-10-31 08:34:19 $
 
 New in 1.28: Corrected the 'Using Progression' attribute for
 tranfinite meshes to actually match a real progression; New
 Triangulate plugin; New 2D graphs (space+time charts); Better
 performance of geometrical transformations (Warning: the automatic
-numbering of some automatically created entities has changed);
+numbering of some automatically created entities has changed); New
+text primitives in post-processing views (file format updated to
+version 1.1);
 
 New in 1.27: Added ability to extrude curves with Layers/Recombine
 attributes; New PointSize/LineWidth options; Fixed For/EndFor loops in
-- 
GitLab