From 9396133ef3bb1ffc7f13e1716fbff8f0a809efc4 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Wed, 29 Aug 2007 18:41:06 +0000
Subject: [PATCH] prepare rewrite graph2d

---
 Geo/Geo.cpp              |   5 +-
 Graphics/Draw.cpp        |   6 +-
 Graphics/Draw.h          |  75 +++---
 Graphics/Entity.cpp      |  44 +---
 Graphics/Graph2D.cpp     | 519 +------------------------------------
 Graphics/Graph2D_Old.cpp | 542 +++++++++++++++++++++++++++++++++++++++
 Graphics/Makefile        |   4 +-
 Plugin/CutGrid.cpp       |   4 +-
 Plugin/CutParametric.cpp |   4 +-
 Plugin/Probe.cpp         |   4 +-
 Plugin/StreamLines.cpp   |   4 +-
 Post/PViewOptions.cpp    |   4 +-
 12 files changed, 609 insertions(+), 606 deletions(-)
 create mode 100644 Graphics/Graph2D_Old.cpp

diff --git a/Geo/Geo.cpp b/Geo/Geo.cpp
index 741fdf7ea0..7bc4ebcde0 100644
--- a/Geo/Geo.cpp
+++ b/Geo/Geo.cpp
@@ -1,4 +1,4 @@
-// $Id: Geo.cpp,v 1.93 2007-08-29 14:18:25 geuzaine Exp $
+// $Id: Geo.cpp,v 1.94 2007-08-29 18:41:06 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -56,9 +56,6 @@ void Mesh::free_all()
   Tree_Action(SurfaceLoops, Free_SurfaceLoop); Tree_Delete(SurfaceLoops);
   Tree_Action(Volumes, Free_Volume); Tree_Delete(Volumes);
   List_Action(PhysicalGroups, Free_PhysicalGroup); List_Delete(PhysicalGroups);
-  // don't delete the symbols: for now we assume that symbols live
-  // forever
-  // InitSymbols();
 }
 
 // Comparison routines
diff --git a/Graphics/Draw.cpp b/Graphics/Draw.cpp
index 9e11460e40..afeea37f6c 100644
--- a/Graphics/Draw.cpp
+++ b/Graphics/Draw.cpp
@@ -1,4 +1,4 @@
-// $Id: Draw.cpp,v 1.112 2007-08-25 10:58:34 geuzaine Exp $
+// $Id: Draw.cpp,v 1.113 2007-08-29 18:41:06 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -95,6 +95,10 @@ void Draw2d()
   glTranslated(0., 0., CTX.clip_factor > 1. ? 1./CTX.clip_factor : CTX.clip_factor);
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
+
+  Draw_Graph2D_Old();
+  Draw_Text2D_Old();
+
   Draw_Graph2D();
   Draw_Text2D();
   Draw_OnScreenMessages();
diff --git a/Graphics/Draw.h b/Graphics/Draw.h
index d64eb0a043..ebee4d0410 100644
--- a/Graphics/Draw.h
+++ b/Graphics/Draw.h
@@ -24,56 +24,44 @@
 #include "List.h"
 #include "SBoundingBox3d.h"
 
-class Post_View;
-
 #define GMSH_RENDER    1
 #define GMSH_SELECT    2
 #define GMSH_FEEDBACK  3
 
-void SetOpenglContext(void);
-void ClearOpengl(void);
+void SetOpenglContext();
+void ClearOpengl();
 
 void InitProjection(int xpick=0, int ypick=0, int wpick=0, int hpick=0);
-void InitPosition(void);
-void InitRenderModel(void);
+void InitPosition();
+void InitRenderModel();
 
 void Unproject(double x, double y, double p[3], double d[3]);
 void Viewport2World(double win[3], double xyz[3]);
 void World2Viewport(double xyz[3], double win[3]);
 
-unsigned int PaletteContinuous(Post_View * View, double min, double max, double val);
-unsigned int PaletteContinuousLinear(Post_View * v, double min, double max, double val);
-unsigned int PaletteDiscrete(Post_View * View, int nbi, int i);
+int Fix2DCoordinates(double *x, double *y);
 
-void Draw3d(void);
-void Draw2d(void);
-void DrawPlugin(void (*draw)(void));
-void Draw(void);
+void Draw3d();
+void Draw2d();
+void DrawPlugin(void (*draw)());
+void Draw();
 
 void Draw_String(char *s);
 void Draw_String(char *s, double style);
 void Draw_String_Center(char *s);
 void Draw_String_Right(char *s);
-void Draw_Geom(void);
-void Draw_Mesh(void);
-void Draw_Post_Old(void);
+void Draw_Geom();
+void Draw_Mesh();
 void Draw_Post();
-void Draw_Graph2D(void);
-void Draw_Text2D(void);
-void Draw_Text2D3D(int dim, int timestep, int nb, List_T *td, List_T *tc);
-int Fix2DCoordinates(double *x, double *y);
-void Draw_OnScreenMessages(void);
-void Draw_Scales(void);
-void Draw_Disk(double size, double rint, double x, double y, double z, int light);
+void Draw_Graph2D();
+void Draw_Text2D();
+void Draw_OnScreenMessages();
+void Draw_Scales();
+
 void Draw_Sphere(double size, double x, double y, double z, int light);
 void Draw_Cylinder(double width, double *x, double *y, double *z, int light);
-void Draw_TapCylinder(double width, double val1, double val2, double ValMin, double ValMax, double *x, double *y, double *z, int light);
-void Draw_Point(int type, double size, double *x, double *y, double *z, 
-		int light);
-void Draw_Line(int type, double width, double *x, double *y, double *z,
-	       int light);
-void Draw_Triangle_Overlay(double r, double g, double b,
-			   double *v1, double *v2, double *v3);
+void Draw_TapCylinder(double width, double val1, double val2, double ValMin, 
+		      double ValMax, double *x, double *y, double *z, int light);
 void Draw_Vector(int Type, int Fill,
 		 double relHeadRadius, double relStemLength, double relStemRadius,
 		 double x, double y, double z, double dx, double dy, double dz,
@@ -89,6 +77,33 @@ void Draw_Axes(int mode, int tics[3], char format[3][256], char label[3][256],
 void Draw_Axes(int mode, int tics[3], char format[3][256], char label[3][256],
 	       SBoundingBox3d &bbox);
 
+
+
+
+
+// //////////////// FIXME remove everything below ////////////////////
+
+
+void Draw_Post_Old(void);
+
+void Draw_Graph2D_Old();
+void Draw_Text2D_Old();
+
+void Draw_Text2D3D(int dim, int timestep, int nb, List_T *td, List_T *tc);
+
+void Draw_Point(int type, double size, double *x, double *y, double *z, 
+		int light);
+void Draw_Line(int type, double width, double *x, double *y, double *z,
+	       int light);
+
+
+class Post_View;
+
+unsigned int PaletteContinuous(Post_View * View, double min, double max, double val);
+unsigned int PaletteContinuousLinear(Post_View * v, double min, double max, double val);
+unsigned int PaletteDiscrete(Post_View * View, int nbi, int i);
+
+
 #define ARGS Post_View *View, int preproNormals, \
              double ValMin, double ValMax, 	 \
              double *X, double *Y, double *Z, double *V
diff --git a/Graphics/Entity.cpp b/Graphics/Entity.cpp
index fc7a69ca9d..ade14f6452 100644
--- a/Graphics/Entity.cpp
+++ b/Graphics/Entity.cpp
@@ -1,4 +1,4 @@
-// $Id: Entity.cpp,v 1.75 2007-08-27 13:46:21 geuzaine Exp $
+// $Id: Entity.cpp,v 1.76 2007-08-29 18:41:06 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -65,29 +65,6 @@ void Draw_Sphere(double size, double x, double y, double z, int light)
 }
 
 
-void Draw_Disk(double size, double rint, double x, double y, double z, int light)
-{
-  if(light) glEnable(GL_LIGHTING);
-  static GLUquadricObj *qua;
-  static int first = 1, listnum;
-  double s = size;
-  if(first) {
-    first = 0;
-    qua = gluNewQuadric();
-    listnum = glGenLists(1);
-    glNewList(listnum, GL_COMPILE);
-    gluDisk(qua, rint, 1, 2*CTX.quadric_subdivisions, 2*CTX.quadric_subdivisions);
-    glEndList();
-  }
-
-  glPushMatrix();
-  glTranslated(x, y, z);
-  glScaled(s, s, s);
-  glCallList(listnum);
-  glPopMatrix();
-  glDisable(GL_LIGHTING);
-}
-
 void Draw_TapCylinder(double width, double val1, double val2, 
 		      double ValMin, double ValMax, 
 		      double *x, double *y, double *z, int light)
@@ -180,25 +157,6 @@ void Draw_Line(int type, double width, double *x, double *y, double *z,
   }
 }
 
-void Draw_Triangle_Overlay(double r, double g, double b,
-			   double *v1, double *v2, double *v3)
-{
-  SetOpenglContext();
-  InitProjection();
-  InitPosition();
-  glDisable(GL_DEPTH_TEST);
-  glDrawBuffer(GL_FRONT);
-  glColor3f(r, g, b);
-  glBegin(GL_LINE_LOOP);
-  glVertex3dv(v1);
-  glVertex3dv(v2);
-  glVertex3dv(v3);
-  glEnd();
-  glFlush();
-  glDrawBuffer(GL_BACK);
-  glEnable(GL_DEPTH_TEST);
-}
-
 void Draw_SimpleVector(int arrow, int fill,
 		       double relHeadRadius, double relStemLength, double relStemRadius,
 		       double x, double y, double z,
diff --git a/Graphics/Graph2D.cpp b/Graphics/Graph2D.cpp
index f24b187314..e81edfee3f 100644
--- a/Graphics/Graph2D.cpp
+++ b/Graphics/Graph2D.cpp
@@ -1,4 +1,4 @@
-// $Id: Graph2D.cpp,v 1.59 2007-08-28 22:54:06 geuzaine Exp $
+// $Id: Graph2D.cpp,v 1.60 2007-08-29 18:41:06 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -19,515 +19,14 @@
 // 
 // Please report all bugs and problems to <gmsh@geuz.org>.
 
-#include "Gmsh.h"
 #include "GmshUI.h"
-#include "Context.h"
-#include "Numeric.h"
 #include "Draw.h"
-#include "Views.h"
-#include "gl2ps.h"
-
-extern Context_T CTX;
-
-// 2D graphics (gnuplot style)
-
-static void getval(Post_View * v, int i, int j, double *p1, double *p2,
-                   double *Abs, double *Val)
-{
-  int k;
-  if(v->Type == DRAW_POST_2D_SPACE) {
-    for(k = 0; k < 3; k++) {
-      List_Read(v->SP, j + k, &p2[k]);
-      if(j)
-        p1[k] = p2[k] - p1[k];
-    }
-    *Abs += sqrt(p1[0] * p1[0] + p1[1] * p1[1] + p1[2] * p1[2]);
-    for(k = 0; k < 3; k++) {
-      p1[k] = p2[k];
-    }
-    *Val = ((double *)List_Pointer_Fast(v->SP, j + 3))[v->TimeStep];
-  }
-  else {
-    *Abs = *(double *)List_Pointer_Fast(v->Time, j);
-    *Val = ((double *)List_Pointer_Fast(v->SP, i + 3))[j];
-  }
-}
-
-static void addval(Post_View * v, double Abs, double Val,
-                   double AbsMin, double AbsMax, double ValMin, double ValMax,
-                   double xtop, double width, double ybot, double height,
-                   int numeric)
-{
-  char label[256];
-  double x, y;
-
-  if(AbsMax == AbsMin)
-    x = xtop;
-  else
-    x = xtop + (Abs - AbsMin) / (AbsMax - AbsMin) * width;
-
-  if(v->SaturateValues) {
-    if(Val > ValMax)
-      Val = ValMax;
-    else if(Val < ValMin)
-      Val = ValMin;
-  }
-
-  if(ValMax == ValMin)
-    y = ybot;
-  else
-    y = ybot + (Val - ValMin) / (ValMax - ValMin) * height;
-
-  if(Val >= ValMin && Val <= ValMax) {
-    PaletteContinuousLinear(v, ValMin, ValMax, Val);
-    if(numeric) {
-      glRasterPos2d(x + 3, y + 3);
-      sprintf(label, v->Format, Val);
-      Draw_String(label);
-    }
-    else
-      glVertex2d(x, y);
-  }
-}
-
-
-static void Draw_Graph2D(Post_View * v, double xtop, double ytop, 
-			 double width, double height, double tic)
-{
-  char label[1024];
-  float font_h, font_a;
-  int i, i_inc, i_max, j, j_inc, j_max, k, nb;
-  double dx, dy, dv;
-  double ybot = ytop - height;
-  double Abs, Val, ValMin = 0., ValMax = 0., AbsMin, AbsMax;
-  double p1[3], p2[3];
-
-  glColor4ubv((GLubyte *) & v->color.axes);
-
-  gl_font(CTX.gl_font_enum, CTX.gl_fontsize);
-  font_h = gl_height(); // total font height
-  font_a = gl_height() - gl_descent();  // height above ref pt
-
-  // compute min/max
-
-  switch (v->RangeType) {
-  case DRAW_POST_RANGE_DEFAULT:
-    ValMin = v->Min;
-    ValMax = v->Max;
-    break;
-  case DRAW_POST_RANGE_CUSTOM:
-    ValMin = v->CustomMin;
-    ValMax = v->CustomMax;
-    break;
-  case DRAW_POST_RANGE_PER_STEP:
-    if(v->TimeStepMin && v->TimeStepMax){
-      ValMin = v->TimeStepMin[v->TimeStep];
-      ValMax = v->TimeStepMax[v->TimeStep];
-    }
-    else{ // possible if the view is empty
-      ValMin = v->Min;
-      ValMax = v->Max;
-    }
-    break;
-  }
-
-  if(v->Type == DRAW_POST_2D_SPACE) {
-    AbsMin = AbsMax = 0.;
-    double p1[3] = { 0., 0., 0. }, p2[3];
-    for(i = 0; i < List_Nbr(v->SP); i += List_Nbr(v->SP) / v->NbSP) {
-      for(k = 0; k < 3; k++) {
-        List_Read(v->SP, i + k, &p2[k]);
-        if(i)
-          p1[k] = p2[k] - p1[k];
-      }
-      AbsMax += sqrt(p1[0] * p1[0] + p1[1] * p1[1] + p1[2] * p1[2]);
-      for(k = 0; k < 3; k++) {
-        p1[k] = p2[k];
-      }
-    }
-  }
-  else {
-    AbsMin = *(double *)List_Pointer(v->Time, 0);
-    AbsMax = *(double *)List_Pointer(v->Time, List_Nbr(v->Time) - 1);
-  }
-
-  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);
-
-  // axes + labels
-
-  if(v->Axes) {
-    glBegin(GL_LINE_STRIP);
-    glVertex2d(xtop, ytop);
-    glVertex2d(xtop, ytop - height);
-    glVertex2d(xtop + width, ybot);
-    if(v->Axes > 1) {
-      glVertex2d(xtop + width, ytop);
-      glVertex2d(xtop, ytop);
-    }
-    glEnd();
-    
-    // y
-    if(v->Type == DRAW_POST_2D_SPACE &&
-       ((v->ShowTime == 1 && List_Nbr(v->Time) > 1) ||
-	(v->ShowTime == 2 && List_Nbr(v->Time) > 0))){
-      char tmp[256];
-      sprintf(tmp, v->Format, *(double *)List_Pointer(v->Time, v->TimeStep));
-      sprintf(label, "%s (%s)", v->Name, tmp);
-    }
-    else if(v->Type == DRAW_POST_2D_SPACE &&
-       ((v->ShowTime == 3 && List_Nbr(v->Time) > 1) ||
-	(v->ShowTime == 4 && List_Nbr(v->Time) > 0))){
-      sprintf(label, "%s (%d)", v->Name, v->TimeStep);
-    }
-    else
-      sprintf(label, "%s", v->Name);
-    glRasterPos2d(xtop, ytop + font_h + tic);
-    Draw_String_Center(label);
-
-    // x
-    sprintf(label, "%s", v->AxesLabel[0]);
-    glRasterPos2d(xtop + width / 2, ybot - 2 * font_h - 2 * tic);
-    Draw_String_Center(label);
-  }
-
-  // y tics + horizontal grid
-
-  if(v->NbIso > 0){
-    nb = v->NbIso;
-    if(v->ShowScale && (v->NbIso * font_h > height))
-      nb = (int)floor(height / font_h);
-    dy = height / (double)nb;
-    dv = (ValMax - ValMin) / (double)nb;
-    for(i = 0; i < nb + 1; i++) {
-      if(v->Axes > 0) {
-	glBegin(GL_LINES);
-	glVertex2d(xtop, ytop - i * dy);
-	glVertex2d(xtop + tic, ytop - i * dy);
-	if(v->Axes > 1) {
-	  glVertex2d(xtop + width - tic, ytop - i * dy);
-	  glVertex2d(xtop + width, ytop - i * dy);
-	}
-	glEnd();
-	if(v->Axes > 2 && i != 0 && i != nb) {
-	  glEnable(GL_LINE_STIPPLE);
-	  glLineStipple(1, 0x1111);
-	  gl2psEnable(GL2PS_LINE_STIPPLE);
-	  gl2psLineWidth(1. * CTX.print.eps_line_width_factor);
-	  glBegin(GL_LINES);
-	  glVertex2d(xtop, ytop - i * dy);
-	  glVertex2d(xtop + width, ytop - i * dy);
-	  glEnd();
-	  glDisable(GL_LINE_STIPPLE);
-	  gl2psDisable(GL2PS_LINE_STIPPLE);
-	  gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor);
-	}
-      }
-      if(v->ShowScale) {
-	sprintf(label, v->Format, (i == nb) ? ValMin : (ValMax - i * dv));
-	glRasterPos2d(xtop - 2 * tic, ytop - i * dy - font_a / 3.);
-	Draw_String_Right(label);
-      }
-    }
-  }
-
-  // x tics + vertical grid
-
-  if(v->AxesTics[0] > 0){
-    nb = v->AxesTics[0];
-    if(v->Axes) {
-      sprintf(label, v->AxesFormat[0], -M_PI/1.e4);
-      if((nb-1) * gl_width(label) > width)
-	nb = (int)(width / gl_width(label)) + 1;
-    }
-    if(nb == 1) nb++;
-    
-    dx = width / (double)(nb - 1);
-    
-    for(i = 0; i < nb; i++) {
-      if(v->Axes) {
-	glBegin(GL_LINES);
-	glVertex2d(xtop + i * dx, ybot);
-	glVertex2d(xtop + i * dx, ybot + tic);
-	if(v->Axes > 1) {
-	  glVertex2d(xtop + i * dx, ytop);
-	  glVertex2d(xtop + i * dx, ytop - tic);
-	}
-	glEnd();
-	if(v->Axes > 2 && i != 0 && i != nb - 1) {
-	  glEnable(GL_LINE_STIPPLE);
-	  glLineStipple(1, 0x1111);
-	  gl2psEnable(GL2PS_LINE_STIPPLE);
-	  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);
-	  gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor);
-	}
-	
-	if(nb == 1)
-	  sprintf(label, v->AxesFormat[0], AbsMin);
-	else
-	  sprintf(label, v->AxesFormat[0],
-		  AbsMin + i * (AbsMax - AbsMin) / (double)(nb - 1));
-	glRasterPos2d(xtop + i * dx, ybot - font_h - tic);
-	Draw_String_Center(label);
-      }
-    }
-  }
-
-  // the curve(s)
-
-  glPointSize(v->PointSize);
-  gl2psPointSize(v->PointSize * CTX.print.eps_point_size_factor);
-
-  glLineWidth(v->LineWidth);
-  gl2psLineWidth(v->LineWidth * CTX.print.eps_line_width_factor);
-
-  if(v->Type == DRAW_POST_2D_SPACE) {
-    i_inc = 1;
-    i_max = 1;
-    j_inc = List_Nbr(v->SP) / v->NbSP;
-    j_max = List_Nbr(v->SP);
-  }
-  else {
-    i_inc = List_Nbr(v->SP) / v->NbSP;
-    i_max = List_Nbr(v->SP);
-    j_inc = 1;
-    j_max = v->TimeStep + 1;
-  }
-
-  for(i = 0; i < i_max; i += i_inc) {
-    if(v->IntervalsType == DRAW_POST_ISO ||
-       v->IntervalsType == DRAW_POST_DISCRETE ||
-       v->IntervalsType == DRAW_POST_NUMERIC) {
-      glBegin(GL_POINTS);
-      Abs = Val = p1[0] = p1[1] = p1[2] = 0.;
-      for(j = 0; j < j_max; j += j_inc) {
-        getval(v, i, j, p1, p2, &Abs, &Val);
-        addval(v, Abs, Val, AbsMin, AbsMax, ValMin, ValMax, xtop, width, ybot,
-               height, 0);
-      }
-      glEnd();
-    }
-    if(v->IntervalsType == DRAW_POST_NUMERIC) {
-      Abs = Val = p1[0] = p1[1] = p1[2] = 0.;
-      for(j = 0; j < j_max; j += j_inc) {
-        getval(v, i, j, p1, p2, &Abs, &Val);
-        addval(v, Abs, Val, AbsMin, AbsMax, ValMin, ValMax, xtop, width, ybot,
-               height, 1);
-      }
-    }
-    if(v->IntervalsType == DRAW_POST_DISCRETE ||
-       v->IntervalsType == DRAW_POST_CONTINUOUS) {
-      if(v->UseStipple){
-	glEnable(GL_LINE_STIPPLE);
-	glLineStipple(v->Stipple[(i/i_inc)%10][0], v->Stipple[(i/i_inc)%10][1]);
-	gl2psEnable(GL2PS_LINE_STIPPLE);
-      }
-      glBegin(GL_LINE_STRIP);
-      Abs = Val = p1[0] = p1[1] = p1[2] = 0.;
-      for(j = 0; j < j_max; j += j_inc) {
-        getval(v, i, j, p1, p2, &Abs, &Val);
-        addval(v, Abs, Val, AbsMin, AbsMax, ValMin, ValMax, xtop, width, ybot,
-               height, 0);
-      }
-      glEnd();
-      if(v->UseStipple){
-	glDisable(GL_LINE_STIPPLE);
-	gl2psDisable(GL2PS_LINE_STIPPLE);
-      }
-    }
-  }
-
-}
-
-void Draw_Graph2D(void)
-{
-  static List_T *todraw = NULL;
-
-  if(!CTX.post.list)
-    return;
-
-  // 2d graphs to draw?
-
-  if(!todraw)
-    todraw = List_Create(5, 5, sizeof(Post_View *));
-  else
-    List_Reset(todraw);
-
-  gl_font(CTX.gl_font_enum, CTX.gl_fontsize);
-  char label[1024];
-  double largest_number = 0.;
-
-  for(int i = 0; i < List_Nbr(CTX.post.list); i++) {
-    Post_View *v = *(Post_View **) List_Pointer(CTX.post.list, i);
-    if(v->Visible && !v->Dirty && v->NbSP && v->Type != DRAW_POST_3D){
-      List_Add(todraw, &v);
-      sprintf(label, v->Format, -M_PI/1.e4);
-      if(largest_number < gl_width(label))
-	largest_number = gl_width(label);
-    }
-  }
-  
-  if(!List_Nbr(todraw))
-    return;
-
-  const double tic = 5;
-  double xsep = largest_number;
-  double ysep = 5 * gl_height();
-  
-  int num = 0;
-
-  for(int i = 0; i < List_Nbr(todraw); i++) {
-    Post_View *v = *(Post_View **) List_Pointer(todraw, i);
-
-    if(!v->AutoPosition) {
-      double x = v->Position[0], y = v->Position[1];
-      int center = Fix2DCoordinates(&x, &y);
-      Draw_Graph2D(v, 
-		   x - (center & 1 ? v->Size[0]/2. : 0), 
-		   y + (center & 2 ? v->Size[1]/2. : 0), 
-		   v->Size[0], v->Size[1], tic);
-    }
-    else{
-      double winw = CTX.viewport[2] - CTX.viewport[0];
-      double winh = CTX.viewport[3] - CTX.viewport[1];
-      if(List_Nbr(todraw) == 1){
-	double fracw = 0.75, frach = 0.75;
-	double w = fracw * winw - xsep;
-	double h = frach * winh - ysep;
-	double xmin = CTX.viewport[0] + (1-fracw)/2. * winw;
-	double ymin = CTX.viewport[1] + (1-frach)/2. * winh;
-	Draw_Graph2D(v, xmin + 0.95*xsep, CTX.viewport[3] - (ymin + 0.4*ysep), w, h, tic);
-      }
-      else if(List_Nbr(todraw) == 2){
-	double fracw = 0.75, frach = 0.85;
-	double w = fracw * winw - xsep;
-	double h = frach * winh / 2. - ysep;
-	double xmin = CTX.viewport[0] + (1-fracw)/2. * winw;
-	double ymin = CTX.viewport[1] + (1-frach)/3. * winh;
-	if(num == 1) ymin += (h + ysep + (1-frach)/3. * winh);
-	Draw_Graph2D(v, xmin + 0.95*xsep, CTX.viewport[3] - (ymin + 0.4*ysep), w, h, tic);
-	num++;
-      }
-      else{
-	double fracw = 0.85, frach = 0.85;
-	double w = fracw * winw / 2. - xsep;
-	double h = frach * winh / 2. - ysep;
-	double xmin = CTX.viewport[0] + (1-fracw)/3. * winw;
-	if(num == 1 || num == 3) xmin += (w + xsep + (1-fracw)/3. * winw);
-	double ymin = CTX.viewport[1] + (1-frach)/3. * winh;
-	if(num == 2 || num == 3) ymin += (h + ysep + (1-frach)/3. * winh);
-	Draw_Graph2D(v, xmin + 0.95*xsep, CTX.viewport[3] - (ymin + 0.4*ysep), w, h, tic);
-	num++;
-      }
-    }
-  }
-}
-
-// Text strings
+#include "PView.h"
 
-int Fix2DCoordinates(double *x, double *y)
+void Draw_Graph2D()
 {
-  int ret = (*x > 99999 && *y > 99999) ? 3 : (*y > 99999) ? 2 : (*x > 99999) ? 1 : 0;
-
-  if(*x < 0) // measure from right border
-    *x = CTX.viewport[2] + *x;
-  else if(*x > 99999) // by convention, x-centered
-    *x = CTX.viewport[2]/2;
-
-  if(*y < 0) // measure from bottom border
-    *y = -(*y);
-  else if(*y > 99999) // by convention, y-centered
-    *y = CTX.viewport[3]/2.;
-  else
-    *y = CTX.viewport[3] - *y;
-  return ret;
 }
 
-// Parser format: T2(x,y,style){"str","str",...};
-// T2D list of double : x,y,style,index,x,y,style,index,...
-// T2C list of chars  : string\0,string\0,string\0,string\0,...
-
-// Parser format: T3(x,y,z,style){"str","str",...};
-// T3D list of double: x,y,z,style,index,x,y,z,style,index,...
-// T3C list of chars: string\0,string\0,string\0,string\0,...
-
-void Draw_Text2D3D(int dim, int timestep, int nb, List_T * td, List_T * tc)
-{
-  int j, k, l, nbd, index, nbchar;
-  char *c;
-  double *d1, *d2, style, x, y, z;
-
-  if(dim == 2)
-    nbd = 4;
-  else if(dim == 3)
-    nbd = 5;
-  else
-    return;
-
-#if 0   //debug
-  if(nb) {
-    for(j = 0; j < List_Nbr(tc); j++) {
-      c = (char *)List_Pointer(tc, j);
-      if(*c == '\0')
-        printf("|");
-      else
-        printf("%c", *c);
-    }
-    printf("\n");
-  }
-#endif
-
-  for(j = 0; j < nb; j++) {
-    d1 = (double *)List_Pointer(td, j * nbd);
-    d2 = (double *)List_Pointer_Test(td, (j + 1) * nbd);
-    if(dim == 2) {
-      x = d1[0];
-      y = d1[1];
-      z = 0.;
-      Fix2DCoordinates(&x, &y);
-      style = d1[2];
-      index = (int)d1[3];
-      if(d2)
-        nbchar = (int)d2[3] - index;
-      else
-        nbchar = List_Nbr(tc) - index;
-    }
-    else {
-      x = d1[0];
-      y = d1[1];
-      z = d1[2];
-      style = d1[3];
-      index = (int)d1[4];
-      if(d2)
-        nbchar = (int)d2[4] - index;
-      else
-        nbchar = List_Nbr(tc) - index;
-    }
-    glRasterPos3d(x, y, z);
-    c = (char *)List_Pointer(tc, index);
-    k = l = 0;
-    while(k < nbchar && l != timestep) {
-      if(c[k++] == '\0')
-        l++;
-    }
-    if(k < nbchar && l == timestep)
-      Draw_String(&c[k], style);
-    else
-      Draw_String(c, style);
-  }
-}
-
-#include "PView.h"
-
 void Draw_Text2D()
 {
   for(unsigned int i = 0; i < PView::list.size(); i++){
@@ -545,16 +44,4 @@ void Draw_Text2D()
       }
     }
   }
-
-  ///////// remove this ////////
-
-  if(!CTX.post.list)
-    return;
-  for(int i = 0; i < List_Nbr(CTX.post.list); i++) {
-    Post_View *v = *(Post_View **) List_Pointer(CTX.post.list, i);
-    if(v->Visible && !v->Dirty && v->DrawStrings){
-      glColor4ubv((GLubyte *) & v->color.text2d);
-      Draw_Text2D3D(2, v->TimeStep, v->NbT2, v->T2D, v->T2C);
-    }
-  }
 }
diff --git a/Graphics/Graph2D_Old.cpp b/Graphics/Graph2D_Old.cpp
new file mode 100644
index 0000000000..4ef54d9a53
--- /dev/null
+++ b/Graphics/Graph2D_Old.cpp
@@ -0,0 +1,542 @@
+// $Id: Graph2D_Old.cpp,v 1.1 2007-08-29 18:41:06 geuzaine Exp $
+//
+// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+// 
+// Please report all bugs and problems to <gmsh@geuz.org>.
+
+#include "Gmsh.h"
+#include "GmshUI.h"
+#include "Context.h"
+#include "Numeric.h"
+#include "Draw.h"
+#include "Views.h"
+#include "gl2ps.h"
+
+extern Context_T CTX;
+
+// 2D graphics (gnuplot style)
+
+static void getval(Post_View * v, int i, int j, double *p1, double *p2,
+                   double *Abs, double *Val)
+{
+  int k;
+  if(v->Type == DRAW_POST_2D_SPACE) {
+    for(k = 0; k < 3; k++) {
+      List_Read(v->SP, j + k, &p2[k]);
+      if(j)
+        p1[k] = p2[k] - p1[k];
+    }
+    *Abs += sqrt(p1[0] * p1[0] + p1[1] * p1[1] + p1[2] * p1[2]);
+    for(k = 0; k < 3; k++) {
+      p1[k] = p2[k];
+    }
+    *Val = ((double *)List_Pointer_Fast(v->SP, j + 3))[v->TimeStep];
+  }
+  else {
+    *Abs = *(double *)List_Pointer_Fast(v->Time, j);
+    *Val = ((double *)List_Pointer_Fast(v->SP, i + 3))[j];
+  }
+}
+
+static void addval(Post_View * v, double Abs, double Val,
+                   double AbsMin, double AbsMax, double ValMin, double ValMax,
+                   double xtop, double width, double ybot, double height,
+                   int numeric)
+{
+  char label[256];
+  double x, y;
+
+  if(AbsMax == AbsMin)
+    x = xtop;
+  else
+    x = xtop + (Abs - AbsMin) / (AbsMax - AbsMin) * width;
+
+  if(v->SaturateValues) {
+    if(Val > ValMax)
+      Val = ValMax;
+    else if(Val < ValMin)
+      Val = ValMin;
+  }
+
+  if(ValMax == ValMin)
+    y = ybot;
+  else
+    y = ybot + (Val - ValMin) / (ValMax - ValMin) * height;
+
+  if(Val >= ValMin && Val <= ValMax) {
+    PaletteContinuousLinear(v, ValMin, ValMax, Val);
+    if(numeric) {
+      glRasterPos2d(x + 3, y + 3);
+      sprintf(label, v->Format, Val);
+      Draw_String(label);
+    }
+    else
+      glVertex2d(x, y);
+  }
+}
+
+
+static void Draw_Graph2D(Post_View * v, double xtop, double ytop, 
+			 double width, double height, double tic)
+{
+  char label[1024];
+  float font_h, font_a;
+  int i, i_inc, i_max, j, j_inc, j_max, k, nb;
+  double dx, dy, dv;
+  double ybot = ytop - height;
+  double Abs, Val, ValMin = 0., ValMax = 0., AbsMin, AbsMax;
+  double p1[3], p2[3];
+
+  glColor4ubv((GLubyte *) & v->color.axes);
+
+  gl_font(CTX.gl_font_enum, CTX.gl_fontsize);
+  font_h = gl_height(); // total font height
+  font_a = gl_height() - gl_descent();  // height above ref pt
+
+  // compute min/max
+
+  switch (v->RangeType) {
+  case DRAW_POST_RANGE_DEFAULT:
+    ValMin = v->Min;
+    ValMax = v->Max;
+    break;
+  case DRAW_POST_RANGE_CUSTOM:
+    ValMin = v->CustomMin;
+    ValMax = v->CustomMax;
+    break;
+  case DRAW_POST_RANGE_PER_STEP:
+    if(v->TimeStepMin && v->TimeStepMax){
+      ValMin = v->TimeStepMin[v->TimeStep];
+      ValMax = v->TimeStepMax[v->TimeStep];
+    }
+    else{ // possible if the view is empty
+      ValMin = v->Min;
+      ValMax = v->Max;
+    }
+    break;
+  }
+
+  if(v->Type == DRAW_POST_2D_SPACE) {
+    AbsMin = AbsMax = 0.;
+    double p1[3] = { 0., 0., 0. }, p2[3];
+    for(i = 0; i < List_Nbr(v->SP); i += List_Nbr(v->SP) / v->NbSP) {
+      for(k = 0; k < 3; k++) {
+        List_Read(v->SP, i + k, &p2[k]);
+        if(i)
+          p1[k] = p2[k] - p1[k];
+      }
+      AbsMax += sqrt(p1[0] * p1[0] + p1[1] * p1[1] + p1[2] * p1[2]);
+      for(k = 0; k < 3; k++) {
+        p1[k] = p2[k];
+      }
+    }
+  }
+  else {
+    AbsMin = *(double *)List_Pointer(v->Time, 0);
+    AbsMax = *(double *)List_Pointer(v->Time, List_Nbr(v->Time) - 1);
+  }
+
+  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);
+
+  // axes + labels
+
+  if(v->Axes) {
+    glBegin(GL_LINE_STRIP);
+    glVertex2d(xtop, ytop);
+    glVertex2d(xtop, ytop - height);
+    glVertex2d(xtop + width, ybot);
+    if(v->Axes > 1) {
+      glVertex2d(xtop + width, ytop);
+      glVertex2d(xtop, ytop);
+    }
+    glEnd();
+    
+    // y
+    if(v->Type == DRAW_POST_2D_SPACE &&
+       ((v->ShowTime == 1 && List_Nbr(v->Time) > 1) ||
+	(v->ShowTime == 2 && List_Nbr(v->Time) > 0))){
+      char tmp[256];
+      sprintf(tmp, v->Format, *(double *)List_Pointer(v->Time, v->TimeStep));
+      sprintf(label, "%s (%s)", v->Name, tmp);
+    }
+    else if(v->Type == DRAW_POST_2D_SPACE &&
+       ((v->ShowTime == 3 && List_Nbr(v->Time) > 1) ||
+	(v->ShowTime == 4 && List_Nbr(v->Time) > 0))){
+      sprintf(label, "%s (%d)", v->Name, v->TimeStep);
+    }
+    else
+      sprintf(label, "%s", v->Name);
+    glRasterPos2d(xtop, ytop + font_h + tic);
+    Draw_String_Center(label);
+
+    // x
+    sprintf(label, "%s", v->AxesLabel[0]);
+    glRasterPos2d(xtop + width / 2, ybot - 2 * font_h - 2 * tic);
+    Draw_String_Center(label);
+  }
+
+  // y tics + horizontal grid
+
+  if(v->NbIso > 0){
+    nb = v->NbIso;
+    if(v->ShowScale && (v->NbIso * font_h > height))
+      nb = (int)floor(height / font_h);
+    dy = height / (double)nb;
+    dv = (ValMax - ValMin) / (double)nb;
+    for(i = 0; i < nb + 1; i++) {
+      if(v->Axes > 0) {
+	glBegin(GL_LINES);
+	glVertex2d(xtop, ytop - i * dy);
+	glVertex2d(xtop + tic, ytop - i * dy);
+	if(v->Axes > 1) {
+	  glVertex2d(xtop + width - tic, ytop - i * dy);
+	  glVertex2d(xtop + width, ytop - i * dy);
+	}
+	glEnd();
+	if(v->Axes > 2 && i != 0 && i != nb) {
+	  glEnable(GL_LINE_STIPPLE);
+	  glLineStipple(1, 0x1111);
+	  gl2psEnable(GL2PS_LINE_STIPPLE);
+	  gl2psLineWidth(1. * CTX.print.eps_line_width_factor);
+	  glBegin(GL_LINES);
+	  glVertex2d(xtop, ytop - i * dy);
+	  glVertex2d(xtop + width, ytop - i * dy);
+	  glEnd();
+	  glDisable(GL_LINE_STIPPLE);
+	  gl2psDisable(GL2PS_LINE_STIPPLE);
+	  gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor);
+	}
+      }
+      if(v->ShowScale) {
+	sprintf(label, v->Format, (i == nb) ? ValMin : (ValMax - i * dv));
+	glRasterPos2d(xtop - 2 * tic, ytop - i * dy - font_a / 3.);
+	Draw_String_Right(label);
+      }
+    }
+  }
+
+  // x tics + vertical grid
+
+  if(v->AxesTics[0] > 0){
+    nb = v->AxesTics[0];
+    if(v->Axes) {
+      sprintf(label, v->AxesFormat[0], -M_PI/1.e4);
+      if((nb-1) * gl_width(label) > width)
+	nb = (int)(width / gl_width(label)) + 1;
+    }
+    if(nb == 1) nb++;
+    
+    dx = width / (double)(nb - 1);
+    
+    for(i = 0; i < nb; i++) {
+      if(v->Axes) {
+	glBegin(GL_LINES);
+	glVertex2d(xtop + i * dx, ybot);
+	glVertex2d(xtop + i * dx, ybot + tic);
+	if(v->Axes > 1) {
+	  glVertex2d(xtop + i * dx, ytop);
+	  glVertex2d(xtop + i * dx, ytop - tic);
+	}
+	glEnd();
+	if(v->Axes > 2 && i != 0 && i != nb - 1) {
+	  glEnable(GL_LINE_STIPPLE);
+	  glLineStipple(1, 0x1111);
+	  gl2psEnable(GL2PS_LINE_STIPPLE);
+	  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);
+	  gl2psLineWidth(CTX.line_width * CTX.print.eps_line_width_factor);
+	}
+	
+	if(nb == 1)
+	  sprintf(label, v->AxesFormat[0], AbsMin);
+	else
+	  sprintf(label, v->AxesFormat[0],
+		  AbsMin + i * (AbsMax - AbsMin) / (double)(nb - 1));
+	glRasterPos2d(xtop + i * dx, ybot - font_h - tic);
+	Draw_String_Center(label);
+      }
+    }
+  }
+
+  // the curve(s)
+
+  glPointSize(v->PointSize);
+  gl2psPointSize(v->PointSize * CTX.print.eps_point_size_factor);
+
+  glLineWidth(v->LineWidth);
+  gl2psLineWidth(v->LineWidth * CTX.print.eps_line_width_factor);
+
+  if(v->Type == DRAW_POST_2D_SPACE) {
+    i_inc = 1;
+    i_max = 1;
+    j_inc = List_Nbr(v->SP) / v->NbSP;
+    j_max = List_Nbr(v->SP);
+  }
+  else {
+    i_inc = List_Nbr(v->SP) / v->NbSP;
+    i_max = List_Nbr(v->SP);
+    j_inc = 1;
+    j_max = v->TimeStep + 1;
+  }
+
+  for(i = 0; i < i_max; i += i_inc) {
+    if(v->IntervalsType == DRAW_POST_ISO ||
+       v->IntervalsType == DRAW_POST_DISCRETE ||
+       v->IntervalsType == DRAW_POST_NUMERIC) {
+      glBegin(GL_POINTS);
+      Abs = Val = p1[0] = p1[1] = p1[2] = 0.;
+      for(j = 0; j < j_max; j += j_inc) {
+        getval(v, i, j, p1, p2, &Abs, &Val);
+        addval(v, Abs, Val, AbsMin, AbsMax, ValMin, ValMax, xtop, width, ybot,
+               height, 0);
+      }
+      glEnd();
+    }
+    if(v->IntervalsType == DRAW_POST_NUMERIC) {
+      Abs = Val = p1[0] = p1[1] = p1[2] = 0.;
+      for(j = 0; j < j_max; j += j_inc) {
+        getval(v, i, j, p1, p2, &Abs, &Val);
+        addval(v, Abs, Val, AbsMin, AbsMax, ValMin, ValMax, xtop, width, ybot,
+               height, 1);
+      }
+    }
+    if(v->IntervalsType == DRAW_POST_DISCRETE ||
+       v->IntervalsType == DRAW_POST_CONTINUOUS) {
+      if(v->UseStipple){
+	glEnable(GL_LINE_STIPPLE);
+	glLineStipple(v->Stipple[(i/i_inc)%10][0], v->Stipple[(i/i_inc)%10][1]);
+	gl2psEnable(GL2PS_LINE_STIPPLE);
+      }
+      glBegin(GL_LINE_STRIP);
+      Abs = Val = p1[0] = p1[1] = p1[2] = 0.;
+      for(j = 0; j < j_max; j += j_inc) {
+        getval(v, i, j, p1, p2, &Abs, &Val);
+        addval(v, Abs, Val, AbsMin, AbsMax, ValMin, ValMax, xtop, width, ybot,
+               height, 0);
+      }
+      glEnd();
+      if(v->UseStipple){
+	glDisable(GL_LINE_STIPPLE);
+	gl2psDisable(GL2PS_LINE_STIPPLE);
+      }
+    }
+  }
+
+}
+
+void Draw_Graph2D_Old()
+{
+  static List_T *todraw = NULL;
+
+  if(!CTX.post.list)
+    return;
+
+  // 2d graphs to draw?
+
+  if(!todraw)
+    todraw = List_Create(5, 5, sizeof(Post_View *));
+  else
+    List_Reset(todraw);
+
+  gl_font(CTX.gl_font_enum, CTX.gl_fontsize);
+  char label[1024];
+  double largest_number = 0.;
+
+  for(int i = 0; i < List_Nbr(CTX.post.list); i++) {
+    Post_View *v = *(Post_View **) List_Pointer(CTX.post.list, i);
+    if(v->Visible && !v->Dirty && v->NbSP && v->Type != DRAW_POST_3D){
+      List_Add(todraw, &v);
+      sprintf(label, v->Format, -M_PI/1.e4);
+      if(largest_number < gl_width(label))
+	largest_number = gl_width(label);
+    }
+  }
+  
+  if(!List_Nbr(todraw))
+    return;
+
+  const double tic = 5;
+  double xsep = largest_number;
+  double ysep = 5 * gl_height();
+  
+  int num = 0;
+
+  for(int i = 0; i < List_Nbr(todraw); i++) {
+    Post_View *v = *(Post_View **) List_Pointer(todraw, i);
+
+    if(!v->AutoPosition) {
+      double x = v->Position[0], y = v->Position[1];
+      int center = Fix2DCoordinates(&x, &y);
+      Draw_Graph2D(v, 
+		   x - (center & 1 ? v->Size[0]/2. : 0), 
+		   y + (center & 2 ? v->Size[1]/2. : 0), 
+		   v->Size[0], v->Size[1], tic);
+    }
+    else{
+      double winw = CTX.viewport[2] - CTX.viewport[0];
+      double winh = CTX.viewport[3] - CTX.viewport[1];
+      if(List_Nbr(todraw) == 1){
+	double fracw = 0.75, frach = 0.75;
+	double w = fracw * winw - xsep;
+	double h = frach * winh - ysep;
+	double xmin = CTX.viewport[0] + (1-fracw)/2. * winw;
+	double ymin = CTX.viewport[1] + (1-frach)/2. * winh;
+	Draw_Graph2D(v, xmin + 0.95*xsep, CTX.viewport[3] - (ymin + 0.4*ysep), w, h, tic);
+      }
+      else if(List_Nbr(todraw) == 2){
+	double fracw = 0.75, frach = 0.85;
+	double w = fracw * winw - xsep;
+	double h = frach * winh / 2. - ysep;
+	double xmin = CTX.viewport[0] + (1-fracw)/2. * winw;
+	double ymin = CTX.viewport[1] + (1-frach)/3. * winh;
+	if(num == 1) ymin += (h + ysep + (1-frach)/3. * winh);
+	Draw_Graph2D(v, xmin + 0.95*xsep, CTX.viewport[3] - (ymin + 0.4*ysep), w, h, tic);
+	num++;
+      }
+      else{
+	double fracw = 0.85, frach = 0.85;
+	double w = fracw * winw / 2. - xsep;
+	double h = frach * winh / 2. - ysep;
+	double xmin = CTX.viewport[0] + (1-fracw)/3. * winw;
+	if(num == 1 || num == 3) xmin += (w + xsep + (1-fracw)/3. * winw);
+	double ymin = CTX.viewport[1] + (1-frach)/3. * winh;
+	if(num == 2 || num == 3) ymin += (h + ysep + (1-frach)/3. * winh);
+	Draw_Graph2D(v, xmin + 0.95*xsep, CTX.viewport[3] - (ymin + 0.4*ysep), w, h, tic);
+	num++;
+      }
+    }
+  }
+}
+
+// Text strings
+
+int Fix2DCoordinates(double *x, double *y)
+{
+  int ret = (*x > 99999 && *y > 99999) ? 3 : (*y > 99999) ? 2 : (*x > 99999) ? 1 : 0;
+
+  if(*x < 0) // measure from right border
+    *x = CTX.viewport[2] + *x;
+  else if(*x > 99999) // by convention, x-centered
+    *x = CTX.viewport[2]/2;
+
+  if(*y < 0) // measure from bottom border
+    *y = -(*y);
+  else if(*y > 99999) // by convention, y-centered
+    *y = CTX.viewport[3]/2.;
+  else
+    *y = CTX.viewport[3] - *y;
+  return ret;
+}
+
+// Parser format: T2(x,y,style){"str","str",...};
+// T2D list of double : x,y,style,index,x,y,style,index,...
+// T2C list of chars  : string\0,string\0,string\0,string\0,...
+
+// Parser format: T3(x,y,z,style){"str","str",...};
+// T3D list of double: x,y,z,style,index,x,y,z,style,index,...
+// T3C list of chars: string\0,string\0,string\0,string\0,...
+
+void Draw_Text2D3D(int dim, int timestep, int nb, List_T * td, List_T * tc)
+{
+  int j, k, l, nbd, index, nbchar;
+  char *c;
+  double *d1, *d2, style, x, y, z;
+
+  if(dim == 2)
+    nbd = 4;
+  else if(dim == 3)
+    nbd = 5;
+  else
+    return;
+
+#if 0   //debug
+  if(nb) {
+    for(j = 0; j < List_Nbr(tc); j++) {
+      c = (char *)List_Pointer(tc, j);
+      if(*c == '\0')
+        printf("|");
+      else
+        printf("%c", *c);
+    }
+    printf("\n");
+  }
+#endif
+
+  for(j = 0; j < nb; j++) {
+    d1 = (double *)List_Pointer(td, j * nbd);
+    d2 = (double *)List_Pointer_Test(td, (j + 1) * nbd);
+    if(dim == 2) {
+      x = d1[0];
+      y = d1[1];
+      z = 0.;
+      Fix2DCoordinates(&x, &y);
+      style = d1[2];
+      index = (int)d1[3];
+      if(d2)
+        nbchar = (int)d2[3] - index;
+      else
+        nbchar = List_Nbr(tc) - index;
+    }
+    else {
+      x = d1[0];
+      y = d1[1];
+      z = d1[2];
+      style = d1[3];
+      index = (int)d1[4];
+      if(d2)
+        nbchar = (int)d2[4] - index;
+      else
+        nbchar = List_Nbr(tc) - index;
+    }
+    glRasterPos3d(x, y, z);
+    c = (char *)List_Pointer(tc, index);
+    k = l = 0;
+    while(k < nbchar && l != timestep) {
+      if(c[k++] == '\0')
+        l++;
+    }
+    if(k < nbchar && l == timestep)
+      Draw_String(&c[k], style);
+    else
+      Draw_String(c, style);
+  }
+}
+
+#include "PView.h"
+
+void Draw_Text2D_Old()
+{
+  if(!CTX.post.list)
+    return;
+  for(int i = 0; i < List_Nbr(CTX.post.list); i++) {
+    Post_View *v = *(Post_View **) List_Pointer(CTX.post.list, i);
+    if(v->Visible && !v->Dirty && v->DrawStrings){
+      glColor4ubv((GLubyte *) & v->color.text2d);
+      Draw_Text2D3D(2, v->TimeStep, v->NbT2, v->T2D, v->T2C);
+    }
+  }
+}
diff --git a/Graphics/Makefile b/Graphics/Makefile
index 66d678041b..da419ca84f 100644
--- a/Graphics/Makefile
+++ b/Graphics/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.122 2007-08-27 13:46:22 geuzaine Exp $
+# $Id: Makefile,v 1.123 2007-08-29 18:41:06 geuzaine Exp $
 #
 # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 #
@@ -37,7 +37,7 @@ SRC = Draw.cpp \
       Entity.cpp \
       ReadImg.cpp \
       Scale.cpp \
-      Graph2D.cpp \
+      Graph2D_Old.cpp Graph2D.cpp \
       gl2ps.cpp\
       gl2gif.cpp\
       gl2jpeg.cpp\
diff --git a/Plugin/CutGrid.cpp b/Plugin/CutGrid.cpp
index 7df1149e9d..227f44c131 100644
--- a/Plugin/CutGrid.cpp
+++ b/Plugin/CutGrid.cpp
@@ -1,4 +1,4 @@
-// $Id: CutGrid.cpp,v 1.20 2007-05-04 10:45:08 geuzaine Exp $
+// $Id: CutGrid.cpp,v 1.21 2007-08-29 18:41:06 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -86,7 +86,7 @@ void GMSH_CutGridPlugin::draw()
     for(int i = 0; i < getNbU(); ++i){
       for(int j = 0; j < getNbV(); ++j){
 	getPoint(i, j, p);
-	Draw_Point(1, CTX.point_size, &p[0], &p[1], &p[2], 1);
+	Draw_Sphere(CTX.point_size, p[0], p[1], p[2], 1);
       }
     }
   }
diff --git a/Plugin/CutParametric.cpp b/Plugin/CutParametric.cpp
index 01ecb90c8d..6638c9b981 100644
--- a/Plugin/CutParametric.cpp
+++ b/Plugin/CutParametric.cpp
@@ -1,4 +1,4 @@
-// $Id: CutParametric.cpp,v 1.19 2007-05-04 10:45:08 geuzaine Exp $
+// $Id: CutParametric.cpp,v 1.20 2007-08-29 18:41:06 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -142,7 +142,7 @@ void GMSH_CutParametricPlugin::draw()
   }
   else{
     for(unsigned int i = 0; i < x.size(); ++i)
-      Draw_Point(1, CTX.point_size, &x[i], &y[i], &z[i], 1);
+      Draw_Sphere(CTX.point_size, x[i], y[i], z[i], 1);
   }
 #endif
 }
diff --git a/Plugin/Probe.cpp b/Plugin/Probe.cpp
index 5b283273a3..89d33f6755 100644
--- a/Plugin/Probe.cpp
+++ b/Plugin/Probe.cpp
@@ -1,4 +1,4 @@
-// $Id: Probe.cpp,v 1.14 2007-05-04 10:45:09 geuzaine Exp $
+// $Id: Probe.cpp,v 1.15 2007-08-29 18:41:06 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -86,7 +86,7 @@ void GMSH_ProbePlugin::draw()
     glVertex3d(x,y,z-d); glVertex3d(x,y,z+d);
     glEnd();
   }
-  Draw_Point(1, CTX.point_size, &x, &y, &z, 1);
+  Draw_Sphere(CTX.point_size, x, y, z, 1);
 #endif
 }
 
diff --git a/Plugin/StreamLines.cpp b/Plugin/StreamLines.cpp
index cae46780a6..13e82231b0 100644
--- a/Plugin/StreamLines.cpp
+++ b/Plugin/StreamLines.cpp
@@ -1,4 +1,4 @@
-// $Id: StreamLines.cpp,v 1.28 2007-05-21 09:02:39 geuzaine Exp $
+// $Id: StreamLines.cpp,v 1.29 2007-08-29 18:41:06 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -72,7 +72,7 @@ void GMSH_StreamLinesPlugin::draw()
   for(int i = 0; i < getNbU(); ++i){
     for(int j = 0; j < getNbV(); ++j){
       getPoint(i, j, p);
-      Draw_Point(1, CTX.point_size, &p[0], &p[1], &p[2], 1);
+      Draw_Sphere(CTX.point_size, p[0], p[1], p[2], 1);
     }
   }
 #endif
diff --git a/Post/PViewOptions.cpp b/Post/PViewOptions.cpp
index 1c8a40d6b6..8c55d88832 100644
--- a/Post/PViewOptions.cpp
+++ b/Post/PViewOptions.cpp
@@ -1,4 +1,4 @@
-// $Id: PViewOptions.cpp,v 1.12 2007-08-29 14:18:25 geuzaine Exp $
+// $Id: PViewOptions.cpp,v 1.13 2007-08-29 18:41:06 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -57,7 +57,7 @@ PViewOptions::PViewOptions()
   Visible = 1;
   IntervalsType = Continuous;
   //IntervalsType = Discrete;
-  //IntervalsType = Iso;
+  IntervalsType = Iso;
   //IntervalsType = Numeric;
   NbIso = 15;
   ArrowSizeProportional = 1;
-- 
GitLab