Index: /trunk/SophyaPI/PI/Makefile
===================================================================
--- /trunk/SophyaPI/PI/Makefile	(revision 43)
+++ /trunk/SophyaPI/PI/Makefile	(revision 44)
@@ -2,5 +2,5 @@
  
 all: $(LIB)libPI.a
-$(LIB)libPI.a : $(OBJ)piapplgen.o $(OBJ)piapplx.o $(OBJ)pibwdggen.o $(OBJ)pibwdgx.o $(OBJ)picmap.o $(OBJ)picmapgen.o $(OBJ)picmapx.o $(OBJ)picontainergen.o $(OBJ)picontainerx.o $(OBJ)pidrawwin.o $(OBJ)pifilechogen.o $(OBJ)pifilechox.o $(OBJ)pihisto.o $(OBJ)piimage.o $(OBJ)pilistgen.o $(OBJ)pilistx.o $(OBJ)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.o $(OBJ)pioptmenugen.o $(OBJ)pioptmenux.o $(OBJ)piperiodx.o $(OBJ)pipixmapgen.o $(OBJ)pipixmapx.o $(OBJ)piscdrawwdg.o $(OBJ)pistdwdggen.o $(OBJ)pistdwdgx.o $(OBJ)pistlist.o $(OBJ)piup.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o $(OBJ)psdict.o $(OBJ)psfile.o
+$(LIB)libPI.a : $(OBJ)piapplgen.o $(OBJ)piapplx.o $(OBJ)pibwdggen.o $(OBJ)pibwdgx.o $(OBJ)picmap.o $(OBJ)picmapgen.o $(OBJ)picmapx.o $(OBJ)picontainergen.o $(OBJ)picontainerx.o $(OBJ)pidrawwin.o $(OBJ)pifilechogen.o $(OBJ)pifilechox.o $(OBJ)pihisto.o $(OBJ)piimage.o $(OBJ)pilistgen.o $(OBJ)pilistx.o $(OBJ)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.o $(OBJ)pioptmenugen.o $(OBJ)pioptmenux.o $(OBJ)piperiodx.o $(OBJ)pipixmapgen.o $(OBJ)pipixmapx.o $(OBJ)piscdrawwdg.o $(OBJ)pistdwdggen.o $(OBJ)pistdwdgx.o $(OBJ)pistlist.o $(OBJ)piup.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o $(OBJ)psfile.o
 	$(AR) $(ARFLAGS)  $@ $?
  
@@ -207,7 +207,4 @@
 $(OBJ)pixtbase.o: pixtbase.cc pixtbaseP.h pibwdgx.h pisysdep.h pibwdggen.h \
  piwdgx.h piwdggen.h pimsghandler.h pixtbase.h
-$(OBJ)psdict.o: psdict.cc psfile.h $(INC)defs.h \
- pisysdep.h pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
- picmap.h picmapx.h picmapgen.h
 $(OBJ)psfile.o: psfile.cc psfile.h $(INC)defs.h \
  pisysdep.h pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h \
Index: /trunk/SophyaPI/PI/pibwdggen.h
===================================================================
--- /trunk/SophyaPI/PI/pibwdggen.h	(revision 43)
+++ /trunk/SophyaPI/PI/pibwdggen.h	(revision 44)
@@ -20,4 +20,9 @@
 enum PIFontAtt { PI_NotDefFontAtt = -1,
                  PI_RomanFont = 1, PI_BoldFont = 2, PI_ItalicFont = 4 };
+
+enum PIPaperSize { PI_A4 = 1, PI_A3 = 2, PI_A5 = 3, PI_NotDefPaperSize = 0};
+
+enum PIOrientation { PI_Landscape = 0, PI_Portrait = 1, PI_Auto = 2 } ;
+
 
 enum PILineAtt { PI_NotDefLineAtt = -1,
Index: /trunk/SophyaPI/PI/pibwdgx.cc
===================================================================
--- /trunk/SophyaPI/PI/pibwdgx.cc	(revision 43)
+++ /trunk/SophyaPI/PI/pibwdgx.cc	(revision 44)
@@ -293,5 +293,5 @@
 PILineAtt clatt;
 if(mPSOut)
-mPSOut->DrawMarker((float)x0,(float)y0,mMrk,mFCol);
+mPSOut->DrawMarker((float)x0,(float)y0,mMrk,mFCol,mMrkSz);
 else
 {
@@ -360,5 +360,5 @@
   ytmp[i] = (float)y[i];
 }
-mPSOut->DrawMarkers(xtmp,ytmp,n,mMrk,mFCol);
+mPSOut->DrawMarkers(xtmp,ytmp,n,mMrk,mFCol, mMrkSz);
 free(xtmp);
 free(ytmp);
Index: /trunk/SophyaPI/PI/piwdggen.cc
===================================================================
--- /trunk/SophyaPI/PI/piwdggen.cc	(revision 43)
+++ /trunk/SophyaPI/PI/piwdggen.cc	(revision 44)
@@ -56,5 +56,5 @@
 psf->DrawBox(0., 0., (float)XSize(), (float)YSize());
 sprintf(str,"PIWdgGen::PSPrint() Kind=%ld Name= %s", kind(), Nom().c_str());
-psf->DrawString(5., 5., str);
+psf->DrawString(12., 12., str, PI_Black, PI_RomanFont, 10);
 psf->EndBloc();
 
Index: /trunk/SophyaPI/PI/piwindowgen.cc
===================================================================
--- /trunk/SophyaPI/PI/piwindowgen.cc	(revision 43)
+++ /trunk/SophyaPI/PI/piwindowgen.cc	(revision 44)
@@ -20,7 +20,7 @@
 {
 if (!psf) return;
-int ori;
-ori = (XSize() > YSize()) ? LANDSCAPE : PORTRAIT ;
-psf->NewPage((float)XSize(), (float)YSize(),ori);
+//int ori;
+//ori = (XSize() > YSize()) ? LANDSCAPE : PORTRAIT ;
+psf->NewPage((float)XSize(), (float)YSize(),PI_Auto);
 PIContainerGen::PSPrint(psf, ofx, ofy);
 }
Index: unk/SophyaPI/PI/psdict.cc
===================================================================
--- /trunk/SophyaPI/PI/psdict.cc	(revision 43)
+++ 	(revision )
@@ -1,429 +1,0 @@
-/*
- *  PSDict.cc
- *
- *  Fonctions d'IO qui ecrivent effectivement le code PostScript
- *   dans les fichiers
- */
-#include <stdio.h>
-#include <time.h>
-#include "psfile.h"
-
-
-/*****************************************************************/
-/****               Gestion du PostScript                     ****/
-/*****************************************************************/
-#define PIDICT_PAR   \
-  \
-  LANDSCAPE, PORTRAIT,\
-  \
-  PI_Black, PI_White, PI_Grey, PI_Red, PI_Blue,\
-  PI_Green, PI_Yellow, PI_Magenta, PI_NotDefColor,\
-  \
-  PI_RomanFont, PI_BoldFont, PI_ItalicFont, PI_NotDefFontAtt,\
-  PI_SmallSizeFont, PI_NormalSizeFont, PI_BigSizeFont, PI_NotDefFontSize, \
-  \
-  PI_NormalLine, PI_ThinLine, PI_ThickLine, PI_NotDefLineAtt
-
-#define PIDICT       "\
-/$PIDict 50 dict def\n\
-$PIDict begin $PIDict /mtrx matrix put /Landscape %d def /Portrait %d def\n\
-%% Couleurs et fontes courantes\n\
-/C%-2d  {0.0   0.0   0.0   setrgbcolor} bind def %% PI_Black\n\
-/C%-2d  {0.996 0.996 0.996 setrgbcolor} bind def %% PI_White\n\
-/C%-2d  {0.824 0.824 0.824 setrgbcolor} bind def %% PI_Grey\n\
-/C%-2d  {0.996 0.0   0.0   setrgbcolor} bind def %% PI_Red\n\
-/C%-2d  {0.0   0.0   0.996 setrgbcolor} bind def %% PI_Blue\n\
-/C%-2d  {0.0   0.996 0.0   setrgbcolor} bind def %% PI_Green\n\
-/C%-2d  {0.996 0.996 0.0   setrgbcolor} bind def %% PI_Yellow\n\
-/C%-2d  {0.996 0.0   0.996 setrgbcolor} bind def %% PI_Magenta\n\
-/C%-2d  {}                              bind def %% PI_NotDefColor\n\
-/F%-2d  {/Times-Roman   findfont} bind def       %% PI_RomanFont\n\
-/F%-2d  {/Times-Bold    findfont} bind def       %% PI_BoldFont\n\
-/F%-2d  {/Times-Italic  findfont} bind def       %% PI_ItalicFont\n\
-/F%-2d  {}\
-                        bind def       %% PI_NotDefFontAtt\n\
-/FS {scalefont setfont} bind def\n\
-%%/FS%-2d {8  scalefont setfont} bind def          %% PI_SmallSizeFont\n\
-%%/FS%-2d {12 scalefont setfont} bind def          %% PI_NormalSizeFont\n\
-%%/FS%-2d {16 scalefont setfont} bind def          %% PI_BigSizeFont\n\
-/FS%-2d {}                     bind def          %% PI_NotDefFontSize\n\
-/L%-2d  {1    slw} bind def                      %% PI_NormalLine\n\
-/L%-2d  {0.5  slw} bind def                      %% PI_ThinLine\n\
-/L%-2d  {3    slw} bind def                      %% PI_ThickLine\n\
-/L%-2d  {}         bind def                      %% PI_NotDefLineAtt\n\
-\
-%% Conversion\n\
-/cm   {28.3 mul}   bind def  %% cm --> points\n\
-/Ux   {$Cvrtx mul} bind def  %% Unites utilisateur /x --> points\n\
-/Uy   {$Cvrty mul} bind def  %% Unites utilisateur /y --> points\n\
-\
-%% Pages et Blocs\n\
-/newref  {%% Dx Dy Tx Ty X0 Y0 newref\n\
-translate 3 -1 roll cm div 28.3 mul /$Cvrty exch def\n\
-exch cm div 28.3 mul /$Cvrtx exch def} bind def\n\
-/NewPage {%% Dx Dy orientation NewPage\n\
-/$PageEnteredState save def 1 -1 scale Portrait eq {w cm h cm 0 h cm neg\n\
-newref} { -90 rotate h cm w cm 0 0 newref} ifelse} bind def\n\
-/EndPage { %% EndPage\n\
-$PageEnteredState restore} bind def\n\
-/NewBloc { %% Dx Dy Tx Ty X0 Y0 NewBloc\n\
-/$BlocEnteredState save def newref} bind def\n\
-/EndBloc { %% EndBloc\n\
-$BlocEnteredState restore} bind def\n\
-\
-%% Trace\n\
-/n  {newpath} bind def    /c  {closepath} bind def\n\
-/gs {gsave}  bind def     /gr {grestore} bind def\n\
-/m  {moveto} bind def     /l  {lineto} bind def\n\
-/s  {stroke} bind def     /f  {fill}   bind def\n\
-/sc {scale}  bind def     /S  {gs 1 -1 sc show gr} bind def \n\
-/slw {setlinewidth} bind def\n\
-/ff {findfont} bind def   /sf {setfont} bind def /scf {scalefont} bind def\n\
-/rl {rlineto} bind def    /tr {translate} bind def\n\
-%% Tx Ty X0 Y0 box\n\
-/box {tr 0 3 1 roll neg exch 0 0 3 index neg 0 0 m rl rl rl c} bind def\n\
-%% R X0 Y0 circle\n\
-/circle {tr dup 0 m 0 0 3 -1 roll 0 380 arc} bind def\n\
-%% DrawEllipse pompee sur transfig\n\
-/ellipse {/endangle exch def /startangle exch def /yrad exch def\n\
-/xrad exch def /y exch def /x exch def /savematrix mtrx currentmatrix def\n\
-x y tr xrad yrad sc 0 0 1 startangle endangle arc\n\
-closepath savematrix setmatrix } def\n\
-\
-%% Gestion des images\n\
-%% ColorImage, pompee sur xv (qui les avait pompees sur xgrab)\n\
-/colorimage where   %% do we know about 'colorimage'?\n\
-  { pop }           %% yes: pop off the 'dict' returned\n\
-  {                 %% no:  define one\n\
-    /colortogray {  %% define an RGB->I function\n\
-      /rgbdata exch store    %% call input 'rgbdata'\n\
-      rgbdata length 3 idiv\n\
-      /npixls exch store\n\
-      /rgbindx 0 store\n\
-      0 1 npixls 1 sub {\n\
-        grays exch\n\
-        rgbdata rgbindx       get 20 mul    %% Red\n\
-        rgbdata rgbindx 1 add get 32 mul    %% Green\n\
-        rgbdata rgbindx 2 add get 12 mul    %% Blue\n\
-        add add 64 idiv      %% I = .5G + .31R + .18B\n\
-        put\n\
-        /rgbindx rgbindx 3 add store\n\
-      } for\n\
-      grays 0 npixls getinterval\n\
-    } bind def\n\
-    /mergeprocs { %% def\n\
-      dup length 3 -1 roll dup length dup 5 1 roll 3 -1 roll add\n\
-      array cvx dup 3 -1 roll 0 exch putinterval dup 4 2 roll\n\
-      putinterval } bind def\n\
-    /colorimage {\n\
-      pop pop     %% remove 'false 3' operands\n\
-      {colortogray} mergeprocs image} bind def\n\
-  } ifelse          %% end of 'false' case\n\
-\
-%% GetRGB\n\
-/GetRGB { %% ImageStr --> RGBStr\n\
-  /ImageData exch store\n\
-  %% Pour chaque element de ImageData,\n\
-  %% On va chercher les valeurs RGB correspondantes\n\
-  0 1 Taille 1 sub {\n\
-    /i      exch store  %% On met a jour l'indice de parcours\n\
-    ImageData i get     %% Recupere la Indice e val dans la chaine ImData\n\
-    ColorMap exch get   %% On recupere la valeur RGB Correspondante\n\
-    aload pop           %% On met tout ca dans la pile\n\
-    %% Maintenant, on va mettre tout ca dans la chaine RGBStr\n\
-    RGBStr i 3 mul 2 add 3 -1 roll put\n\
-    RGBStr i 3 mul 1 add 3 -1 roll put\n\
-    RGBStr i 3 mul       3 -1 roll put\n\
-    } for\n\
-  RGBStr 0 Taille 3 mul getinterval %% On renvoie la chaine RGB\n\
-} bind def\n\
-end\n\
-"
-
-
-/*****************************************************************/
-/****                       PIMarkers                         ****/
-/*****************************************************************/
-#define PIMARKERS_PAR  PI_DotMarker, PI_PlusMarker, PI_CrossMarker,\
-  PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,\
-  PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker
-
-#define PIMARKERS  "\
-%% Definition de la fonte $PIMarkers\n\
-/$PIMarkers 26 dict def\n\
-$PIMarkers begin\n\
-/FontType 3 def\n\
-/FontMatrix [0.001 0 0 0.001 -0.375 -0.375] def\n\
-/FontBBox   [0 0 1000 1000] def\n\
-/Encoding 256 array def\n\
-0 1 255 {Encoding exch /.notdef put} for\n\
-Encoding  %d /PIDot       put %% PI_DotMarker\n\
-Encoding  %d /PIPlus      put %% PI_PlusMarker\n\
-Encoding  %d /PICross     put %% PI_CrossMarker\n\
-Encoding  %d /PICircle    put %% PI_CircleMarker\n\
-Encoding  %d /PIFCircle   put %% PI_FCircleMarker\n\
-Encoding  %d /PIBox       put %% PI_BoxMarker\n\
-Encoding  %d /PIFBox      put %% PI_FBoxMarker\n\
-Encoding  %d /PITriangle  put %% PI_TriangleMarker\n\
-Encoding  %d /PIFTriangle put %% PI_FTriangleMarker\n\
-Encoding  %d /PIStar      put %% PI_StarMarker\n\
-Encoding  %d /PIFStar     put %% PI_FStarMarker\n\
-/CharProcs 26 dict def\n\
-$PIDict begin\n\
-CharProcs begin\n\
-/.notdef     {} def\n\
-/PIDot       {100 375 375 circle f} bind def\n\
-/PIPlus      {0 375 m 750 375 l 375 0 m 375 750 l s} bind def\n\
-/PICross     {0 0 m 750 750 l 750 0 m 0 750 l s} bind def\n\
-/PICircle    {375 375 375 circle s} bind def\n\
-/PIFCircle   {375 375 375 circle f} bind def\n\
-/PIBox       {0 0 m 750 0 l 750 750 l 0 750 l c s} bind def\n\
-/PIFBox      {0 0 m 750 0 l 750 750 l 0 750 l c f} bind def\n\
-/PITriangle  {0 750 m 375 0 l 750 750 l c s} bind def\n\
-/PIFTriangle {0 750 m 375 0 l 750 750 l c f} bind def\n\
-/PIStar      {} def\n\
-/PIFStar     {} def\n\
-end %%$PIDict\n\
-end %%$CharProcs\n\
-/BuildChar {\n\
-1000 0      %% Largeur \n\
-0 0 750 750 %% Bounding Box\n\
-setcachedevice \n\
-exch begin\n\
-Encoding exch get\n\
-CharProcs exch get\n\
-end exec} def\n\
-end\n\
-/PIMarkers $PIMarkers definefont pop\n\
-save\n\
-"
-
-
-
-#define END_PROLOG_PAR  PAGE_WIDTH, PAGE_HEIGHT
-#define END_PROLOG  "/NewFile { %%%% w h NewFile (--> h et w en cm <--)\n\
-$PIDict begin /PIMarkers ff 14 scf sf /h exch def /w exch def \n\
-/$PIEnteredState save def} bind def\n\
-/EndFile {$PIEnteredState restore end} bind def\n\
-%%%%EndProlog\n\n\
-"
-
-
-#define HEADER_PS  "%%!PS-Adobe-2.0\n"
-#define HEADER_EPS "%%!PS-Adobe-2.0 EPSF-2.0\n%%%%BoundingBox: %d %d %d %d\n"
-#define HEADER     "\
-%%%%Title: %s\n\
-%%%%Creator: PSFile\n\
-%%%%CreationDate: %s\
-%%%%Pages: (atend)\n\
-%%%%EndComments\n\n\
-"
-void  PSFile::WriteHeader(){
-
-    int X;
-    int Y;
-    int H;
-    int W;
-    time_t timer;
-    char *date = (char*)malloc(64*sizeof(char));
-
-    if(isEPS) {
-        X = (int)(mFormat.X0*28.35);
-        Y = (int)(mFormat.Y0*28.35);
-	W = (int)((mFormat.X0 + mFormat.Tx)*28.35);
-	H = (int)((mFormat.Y0 + mFormat.Ty)*28.35);
-	fprintf(mPSFile,HEADER_EPS, X, Y, W, H);
-    }
-    else
-	fprintf(mPSFile,HEADER_PS);
-
-    time(&timer);
-    date = ctime(&timer);
-    fprintf(mPSFile, HEADER, mPSFileName, date);
-    fprintf(mPSFile, PIDICT, PIDICT_PAR);
-    fprintf(mPSFile, PIMARKERS, PIMARKERS_PAR);
-    fprintf(mPSFile, END_PROLOG);
-    if(!isEPS)
-      fprintf(mPSFile, "%.2f %.2f NewFile\n", END_PROLOG_PAR);
-    else
-      fprintf(mPSFile, "%.2f %.2f NewFile\n", 
-	      mFormat.Tx, mFormat.Ty);
-}
-
-
-void PSFile::WriteTrailer() {
-
-    fprintf(mPSFile, "%%%%Trailer\n%%%%Pages: %d\n%%%%EOF\n", PageCounter);
-}
-
-
-void PSFile::WriteNewPage(Page *mPage) {
-
-    fprintf(mPSFile, "%%%%Page: %d %d\n%.2f %.2f %d NewPage\n",
-	    mPage->num, mPage->num, 
-	    mPage->format.Dx, mPage->format.Dy,
-	    mPage->format.orientation);
-}
-
-void PSFile::WriteEndPage(Page *mPage) {
-
-    fprintf(mPSFile, "EndPage showpage\n");
-    //    if(!isEPS)
-    //	fprintf(mPSFile, "showpage");
-    fprintf(mPSFile, "%%>EndPage %d\n\n\n", mPage->num);
-}
-
-void PSFile::WriteNewBloc(Bloc *mBloc) {
-
-    fprintf(mPSFile, "%%>BeginBloc %d\n", mBloc->num);
-    fprintf(mPSFile, "%.2f %.2f %.2f Ux %.2f Uy %.2f Ux %.2f Uy NewBloc\n",
-	    mBloc->format.Dx, mBloc->format.Dy,
-	    mBloc->format.Tx, mBloc->format.Ty,
-	    mBloc->format.X0, mBloc->format.Y0);
-}
-
-void PSFile::WriteEndBloc(Bloc *mBloc) {
-
-    fprintf(mPSFile, "EndBloc\n");
-    fprintf(mPSFile, "%%>EndBloc %d\n", mBloc->num);
-}
-
-
-
-/*****************************************************************/
-/****                Fonctions de trace                       ****/
-/*****************************************************************/
-void PSFile::WriteDrawString(float x, float y, char * s) {
-    
-    fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s);
-}
-
-void PSFile::WriteDrawLine(float x1, float y1, float x2, float y2) {
-
-    fprintf(mPSFile, "n %.2f Ux %.2f Uy m %.2f Ux %.2f Uy l s\n", 
-	    x1, y1, x2, y2);
-}
-
-void PSFile::WriteDrawBox(float X0, float Y0, float Tx, float Ty) {
-
-    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy box s gr\n",
-	    Tx, Ty, X0, Y0);
-}
-
-void PSFile::WriteDrawFBox(float X0, float Y0, float Tx, float Ty) {
-
-    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy box f gr\n",
-	    Tx, Ty, X0, Y0);
-}
-
-void PSFile::WriteDrawCircle(float X0, float Y0,float R) {
-
-    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy 0 360 ellipse s gr\n",
-	    X0, Y0, R, R);
-}
-
-void PSFile::WriteDrawFCircle(float X0, float Y0,float R) {
-
-    WriteSetColor(mFillColor);
-    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy \
-                      0 360 ellipse f gr\n",
-	    X0, Y0, R, R);
-}
-
-void PSFile::WriteDrawPolygon(float * x, float * y, int n) {
-
-    int i;
-
-    fprintf(mPSFile, "%.2f Ux %.2f Uy m\n", x[0], y[0]);
-    for(i=0; i<n; i++) 
-	fprintf(mPSFile, "%.2f Ux %.2f Uy %.2f Ux %.2f Uy l\n",
-		x[i+1], y[i+1], x[i], y[i]);
-    fprintf(mPSFile, "c s\n");
-}
-
-void PSFile::WriteDrawFPolygon(float * x, float * y, int n) {
-
-    int i;
-
-    fprintf(mPSFile, "%.2f Ux %.2f Uy m\n", x[0], y[0]);
-    for(i=0; i<n; i++) 
-	fprintf(mPSFile, "%.2f Ux %.2f Uy %.2f Ux %.2f Uy l\n",
-		x[i+1], y[i+1], x[i], y[i]);
-    fprintf(mPSFile, "c f\n");
-}
-
-
-void PSFile::WriteDrawMarker(float x, float y) {
-
-    fprintf(mPSFile, "%.2f Ux %.2f Uy m (\\%#o) show\n", 
-	    x, y, mMarker);
-}
-
-
-void PSFile::WriteDrawMarkers(float * x, float * y, int n) {
-
-    for(int i = 0; i<n; i++)
-	fprintf(mPSFile, "%.2f Ux %.2f Uy m (\\%#o) show\n", 
-		x[i], y[i], mMarker);
-}
-
-
-void PSFile::WriteImage(float x0, float y0, float Tx, float Ty,
-			int Nx, int Ny, unsigned char *pixmap, 
-			PIColorMap *mColorMap) {
-
-    int i, j;
-
-    /* Buffers PostScript */
-    fprintf(mPSFile, "/Taille %d def\n", Nx);
-    fprintf(mPSFile, "/ImStr Taille string def\n");
-    fprintf(mPSFile, "/RGBStr Taille 3  mul string def\n");
-
-    /* Ecriture ColorMap */
-    fprintf(mPSFile, "/ColorMap %02d array def\n", mColorMap->NCol() );
-    for(i = 0; i < mColorMap->NCol(); i++) {
-	fprintf(mPSFile, "ColorMap %d [16#%02X 16#%02X 16#%02X] put\n",
-		i,
-		(int)(mColorMap->GetColor(i).red/256),
-		(int)(mColorMap->GetColor(i).green/256),
-		(int)(mColorMap->GetColor(i).blue/256));
-    }
-    /* Emplacement de l'image (et gsave...) */
-    fprintf(mPSFile, "gs %.2f  %.2f  tr %.2f Ux %.2f Uy sc\n", x0, y0, Tx, Ty);
-    /* Nbr pix-X, Nbr pix-Y bits/pixels */
-    fprintf(mPSFile, "%d %d 8\n", Nx, Ny);
-    /* Matrice de passage */
-    fprintf(mPSFile, "[%d 0 0 %d 0 0]", Nx, Ny);
-    /* Fonction colorimage */
-    fprintf(mPSFile, "{currentfile ImStr readhexstring pop GetRGB}\
-false 3 colorimage\n\n");
-    /* Data */
-    for(i = 0; i < Ny; i++) {
-	for(j=0; j<Nx-1; j++ )
-	    fprintf(mPSFile, "%02X", pixmap[i*Nx+j]);
-    fprintf(mPSFile, "%02X\n", pixmap[i*Nx+j]);
-    }
-    /* Un petit grestore ...*/
-    fprintf(mPSFile, "gr\n");
-}
-
-void PSFile::WriteSetColor(PIColors mDrawColor) {
-
-    fprintf(mPSFile, "C%d ", mDrawColor);
-}
-
-void PSFile::WriteSetFont(PIFontAtt mFontAtt, int mFontSize) {
-
-  //  int fntsz;
-  //  PageList::iterator it;
-
-  //  it = mPageList.end(); it--;
-  //  fntsz = (int)(28.3 * mFormat.Tx * ( mFontSize / (*it).format.Tx) );
-  fprintf(mPSFile, "F%d %d Ux FS ", mFontAtt, mFontSize);
-  //  printf("%d %f %f\n",fntsz,(float)mFormat.Tx,(float)(*it).format.Tx);
-}
-
-void PSFile::WriteSetLineWidth(PILineAtt mLineAtt) {
-
-    fprintf(mPSFile, "%d slw ", mLineAtt);
-}
Index: /trunk/SophyaPI/PI/psfile.cc
===================================================================
--- /trunk/SophyaPI/PI/psfile.cc	(revision 43)
+++ /trunk/SophyaPI/PI/psfile.cc	(revision 44)
@@ -4,4 +4,6 @@
  *   19/06/96
  *
+ *   Modification le 01/03/96
+ *    - fusion psfile.cc - psdict.cc
  *
  */
@@ -13,37 +15,326 @@
 #include "psfile.h"
 
-
-
-
-
-extern float cm2pt(float x);
-
+/* En cm */
+#define  MIN_SIZE_IN_PAGE  2.
 
 /*
- *   Premier constructeur :
- *     Creation d'un fichier .ps ou .eps
+ *  Dictionnaire PIDict
+ *
+ *  Contient les fonctions suivantes : 
+ *
  *
  */
-PSFile::PSFile (char *FileName = NULL, float Tx, float Ty,
-		float Dx, float Dy) {
-
-  //    extern int FileEmpty;
-  //    extern int BlocActive;
-  //    extern int PageActive;
-
-    /* Si une bounding box est precisee, on produit du .eps */
-    if ( (Tx != 0) && (Ty != 0) )  isEPS = 1;
-    else   isEPS = 0;
-
-
-    /* Nom du fichier */
-    if ( FileName != NULL ) {
-	mPSFileName = new ( char[strlen(FileName)+1] );
-	strcpy(mPSFileName, FileName);
-    }
-    else {
-	mPSFileName = new ( char[11] );
-	strncpy(mPSFileName, "unnamed.ps", 11);
-    }
+#define PIDICT_PAR   \
+  \
+  PI_Landscape, PI_Portrait,\
+  \
+  PI_Black, PI_White, PI_Grey, PI_Red, PI_Blue,\
+  PI_Green, PI_Yellow, PI_Magenta, PI_NotDefColor,\
+  \
+  PI_RomanFont, PI_BoldFont, PI_ItalicFont, PI_NotDefFontAtt,\
+  PI_SmallSizeFont, PI_NormalSizeFont, PI_BigSizeFont, PI_NotDefFontSize, \
+  \
+  PI_NormalLine, PI_ThinLine, PI_ThickLine, PI_NotDefLineAtt
+
+#define PIDICT       "\
+/$PIDict 50 dict def\n\
+$PIDict begin $PIDict /mtrx matrix put /Landscape %d def /Portrait %d def\n\
+%% Couleurs et fontes courantes\n\
+/C%-2d  {0.0   0.0   0.0   setrgbcolor} bind def %% PI_Black\n\
+/C%-2d  {0.996 0.996 0.996 setrgbcolor} bind def %% PI_White\n\
+/C%-2d  {0.824 0.824 0.824 setrgbcolor} bind def %% PI_Grey\n\
+/C%-2d  {0.996 0.0   0.0   setrgbcolor} bind def %% PI_Red\n\
+/C%-2d  {0.0   0.0   0.996 setrgbcolor} bind def %% PI_Blue\n\
+/C%-2d  {0.0   0.996 0.0   setrgbcolor} bind def %% PI_Green\n\
+/C%-2d  {0.996 0.996 0.0   setrgbcolor} bind def %% PI_Yellow\n\
+/C%-2d  {0.996 0.0   0.996 setrgbcolor} bind def %% PI_Magenta\n\
+/C%-2d  {}                              bind def %% PI_NotDefColor\n\
+/F%-2d  {/Times-Roman   findfont} bind def       %% PI_RomanFont\n\
+/F%-2d  {/Times-Bold    findfont} bind def       %% PI_BoldFont\n\
+/F%-2d  {/Times-Italic  findfont} bind def       %% PI_ItalicFont\n\
+/F%-2d  {}\
+                        bind def       %% PI_NotDefFontAtt\n\
+/FS {scalefont setfont} bind def\n\
+%%/FS%-2d {8  scalefont setfont} bind def          %% PI_SmallSizeFont\n\
+%%/FS%-2d {12 scalefont setfont} bind def          %% PI_NormalSizeFont\n\
+%%/FS%-2d {16 scalefont setfont} bind def          %% PI_BigSizeFont\n\
+/FS%-2d {}                     bind def          %% PI_NotDefFontSize\n\
+/L%-2d  {1    slw} bind def                      %% PI_NormalLine\n\
+/L%-2d  {0.5  slw} bind def                      %% PI_ThinLine\n\
+/L%-2d  {3    slw} bind def                      %% PI_ThickLine\n\
+/L%-2d  {}         bind def                      %% PI_NotDefLineAtt\n\
+\
+%% Conversion\n\
+/cm   {28.3 mul}   bind def  %% cm --> points\n\
+/Ux   {$Cvrtx mul} bind def  %% Unites utilisateur /x --> points\n\
+/Uy   {$Cvrty mul} bind def  %% Unites utilisateur /y --> points\n\
+\
+%% Pages et Blocs\n\
+/newref  {%% Dx Dy Tx Ty X0 Y0 newref\n\
+translate 3 -1 roll cm div 28.3 mul /$Cvrty exch def\n\
+exch cm div 28.3 mul /$Cvrtx exch def} bind def\n\
+/NewPage {%% Dx Dy orientation NewPage\n\
+/$PageEnteredState save def 1 -1 scale Portrait eq {w cm h cm 0 h cm neg\n\
+newref} { -90 rotate h cm w cm 0 0 newref} ifelse} bind def\n\
+/EndPage { %% EndPage\n\
+$PageEnteredState restore} bind def\n\
+/NewBloc { %% Dx Dy Tx Ty X0 Y0 NewBloc\n\
+/$BlocEnteredState save def newref} bind def\n\
+/EndBloc { %% EndBloc\n\
+$BlocEnteredState restore} bind def\n\
+\
+%% Trace\n\
+/n  {newpath} bind def    /c  {closepath} bind def\n\
+/gs {gsave}  bind def     /gr {grestore} bind def\n\
+/m  {moveto} bind def     /l  {lineto} bind def\n\
+/s  {stroke} bind def     /f  {fill}   bind def\n\
+/sc {scale}  bind def     /S  {gs 1 -1 sc show gr} bind def \n\
+/slw {setlinewidth} bind def\n\
+/ff {findfont} bind def   /sf {setfont} bind def /scf {scalefont} bind def\n\
+/rl {rlineto} bind def    /tr {translate} bind def\n\
+%% Tx Ty X0 Y0 box\n\
+/box {tr 0 3 1 roll neg exch 0 0 3 index neg 0 0 m rl rl rl c} bind def\n\
+%% R X0 Y0 circle\n\
+/circle {tr dup 0 m 0 0 3 -1 roll 0 380 arc} bind def\n\
+%% DrawEllipse pompee sur transfig\n\
+/ellipse {/endangle exch def /startangle exch def /yrad exch def\n\
+/xrad exch def /y exch def /x exch def /savematrix mtrx currentmatrix def\n\
+x y tr xrad yrad sc 0 0 1 startangle endangle arc\n\
+closepath savematrix setmatrix } def\n\
+\
+%% Gestion des images\n\
+%% ColorImage, pompee sur xv (qui les avait pompees sur xgrab)\n\
+/colorimage where   %% do we know about 'colorimage'?\n\
+  { pop }           %% yes: pop off the 'dict' returned\n\
+  {                 %% no:  define one\n\
+    /colortogray {  %% define an RGB->I function\n\
+      /rgbdata exch store    %% call input 'rgbdata'\n\
+      rgbdata length 3 idiv\n\
+      /npixls exch store\n\
+      /rgbindx 0 store\n\
+      0 1 npixls 1 sub {\n\
+        grays exch\n\
+        rgbdata rgbindx       get 20 mul    %% Red\n\
+        rgbdata rgbindx 1 add get 32 mul    %% Green\n\
+        rgbdata rgbindx 2 add get 12 mul    %% Blue\n\
+        add add 64 idiv      %% I = .5G + .31R + .18B\n\
+        put\n\
+        /rgbindx rgbindx 3 add store\n\
+      } for\n\
+      grays 0 npixls getinterval\n\
+    } bind def\n\
+    /mergeprocs { %% def\n\
+      dup length 3 -1 roll dup length dup 5 1 roll 3 -1 roll add\n\
+      array cvx dup 3 -1 roll 0 exch putinterval dup 4 2 roll\n\
+      putinterval } bind def\n\
+    /colorimage {\n\
+      pop pop     %% remove 'false 3' operands\n\
+      {colortogray} mergeprocs image} bind def\n\
+  } ifelse          %% end of 'false' case\n\
+\
+%% GetRGB\n\
+/GetRGB { %% ImageStr --> RGBStr\n\
+  /ImageData exch store\n\
+  %% Pour chaque element de ImageData,\n\
+  %% On va chercher les valeurs RGB correspondantes\n\
+  0 1 Taille 1 sub {\n\
+    /i      exch store  %% On met a jour l'indice de parcours\n\
+    ImageData i get     %% Recupere la Indice e val dans la chaine ImData\n\
+    ColorMap exch get   %% On recupere la valeur RGB Correspondante\n\
+    aload pop           %% On met tout ca dans la pile\n\
+    %% Maintenant, on va mettre tout ca dans la chaine RGBStr\n\
+    RGBStr i 3 mul 2 add 3 -1 roll put\n\
+    RGBStr i 3 mul 1 add 3 -1 roll put\n\
+    RGBStr i 3 mul       3 -1 roll put\n\
+    } for\n\
+  RGBStr 0 Taille 3 mul getinterval %% On renvoie la chaine RGB\n\
+} bind def\n\
+end\n\
+"
+
+
+
+/* 
+ *  Les PIMarkers sont definis et geres commes des fontes
+ *
+ *
+ */
+#define PIMARKERS_PAR  PI_DotMarker, PI_PlusMarker, PI_CrossMarker,\
+  PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,\
+  PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker
+
+#define PIMARKERS  "\
+%% Definition de la fonte $PIMarkers\n\
+/$PIMarkers 26 dict def\n\
+$PIMarkers begin\n\
+/FontType 3 def\n\
+/FontMatrix [0.001 0 0 0.001 -0.375 -0.375] def\n\
+/FontBBox   [0 0 1000 1000] def\n\
+/Encoding 256 array def\n\
+0 1 255 {Encoding exch /.notdef put} for\n\
+Encoding  %d /PIDot       put %% PI_DotMarker\n\
+Encoding  %d /PIPlus      put %% PI_PlusMarker\n\
+Encoding  %d /PICross     put %% PI_CrossMarker\n\
+Encoding  %d /PICircle    put %% PI_CircleMarker\n\
+Encoding  %d /PIFCircle   put %% PI_FCircleMarker\n\
+Encoding  %d /PIBox       put %% PI_BoxMarker\n\
+Encoding  %d /PIFBox      put %% PI_FBoxMarker\n\
+Encoding  %d /PITriangle  put %% PI_TriangleMarker\n\
+Encoding  %d /PIFTriangle put %% PI_FTriangleMarker\n\
+Encoding  %d /PIStar      put %% PI_StarMarker\n\
+Encoding  %d /PIFStar     put %% PI_FStarMarker\n\
+/CharProcs 26 dict def\n\
+$PIDict begin\n\
+CharProcs begin\n\
+/.notdef     {} def\n\
+/PIDot       {100 375 375 circle f} bind def\n\
+/PIPlus      {0 375 m 750 375 l 375 0 m 375 750 l s} bind def\n\
+/PICross     {0 0 m 750 750 l 750 0 m 0 750 l s} bind def\n\
+/PICircle    {375 375 375 circle s} bind def\n\
+/PIFCircle   {375 375 375 circle f} bind def\n\
+/PIBox       {0 0 m 750 0 l 750 750 l 0 750 l c s} bind def\n\
+/PIFBox      {0 0 m 750 0 l 750 750 l 0 750 l c f} bind def\n\
+/PITriangle  {0 750 m 375 0 l 750 750 l c s} bind def\n\
+/PIFTriangle {0 750 m 375 0 l 750 750 l c f} bind def\n\
+/PIStar      {} def\n\
+/PIFStar     {} def\n\
+end %%$PIDict\n\
+end %%$CharProcs\n\
+/BuildChar {\n\
+1000 0      %% Largeur \n\
+0 0 750 750 %% Bounding Box\n\
+setcachedevice \n\
+exch begin\n\
+Encoding exch get\n\
+CharProcs exch get\n\
+end exec} def\n\
+end\n\
+/PIMarkers $PIMarkers definefont pop\n\
+save\n\
+"
+
+/* Dimensions des divers formats */
+  struct PaperSize {
+      float width ;
+      float height ;
+  };
+struct PaperSize PaperSizeTable[] = {
+    { 0.0,  0.0},    /* PI_NotDefFormat */
+    {21.0, 29.7},    /* PI_A4 */
+    {29.7, 42.0},    /* PI_A3 */
+    {14.8, 21.0}     /* PI_A5 ? */
+} ;
+
+
+float cm2pt(float x);
+
+
+/* Fonction WriteHeader */
+#define END_PROLOG_PAR  PAGE_WIDTH, PAGE_HEIGHT
+#define END_PROLOG  "/NewFile { %%%% w h NewFile (--> h et w en cm <--)\n\
+$PIDict begin /PIMarkers ff 14 scf sf /h exch def /w exch def \n\
+/$PIEnteredState save def} bind def\n\
+/EndFile {$PIEnteredState restore end} bind def\n\
+%%%%EndProlog\n\n\
+"
+
+#define HEADER     "\
+%%%%Title: %s\n\
+%%%%Creator: PSFile\n\
+%%%%CreationDate: %s\
+%%%%Pages: (atend)\n\
+%%%%EndComments\n\n\
+"
+
+
+/* 
+ *   PostScript encapsule...
+ * 
+ *   Attention la bounding Box ne sera specifiee 
+ *     qu'au premier NewPage() --> definie dans 
+ *     le champ "Trailer" 
+ *
+ */
+PSFile::PSFile(char * FileName, float sc) 
+    : mPSFileName(FileName==NULL? "unnamed.eps" : FileName),
+      Tw (-1.), Th(-1.),         /* Non specifies pour du eps  */
+      WMargin (-1), HMargin(-1), /* Non specifiees en eps  */ 
+      isEPS(1),
+      scale(sc),                 /* Defaut : 1. */
+      mPaperSize(PI_NotDefPaperSize), /* Non specifiee en eps */
+      PageCounter(0),            /* Fichier vide */
+      FileEmpty(1),              /* Fichier vide */
+      currentPage(NULL),
+      currentBloc(NULL),
+      mDrawColor(PI_Black),
+      mFillColor(PI_Black),
+      mFontAtt(PI_RomanFont),
+      mFontSize(PI_NormalSizeFont),
+      mLineAtt(PI_NormalLine),
+      mMarker(PI_DotMarker)
+{
+    char*  date = new (char[64] ) ; 
+    time_t timer ; 
+
+    /* Ouverture du fichier en mode w+ */
+    if ( (mPSFile = fopen(FileName, "w+")) == NULL){
+	  perror (FileName);
+	  return;
+    }
+
+    /* Ecriture du Header  */
+    fprintf(mPSFile, "%%!PS-Adobe-2.0 EPSF-2.0\n");
+    fprintf(mPSFile, "%%%%BoundingBox: ");
+    /* 
+     * Les dimensions de la BB seront notees ici lors du 
+     * premier appel a NewPage
+     *
+     * C'est laid... si qqn a une meilleure idee...
+     */
+    boundingBox = ftell(mPSFile) ; 
+    fprintf(mPSFile, "                       \n");
+
+    time(&timer) ; 
+    date = ctime(&timer) ; 
+    fprintf(mPSFile, HEADER, mPSFileName, date) ; /* titre, date etc... */
+    fprintf(mPSFile, PIDICT, PIDICT_PAR) ;        /* Dictionnaire */
+    fprintf(mPSFile, PIMARKERS, PIMARKERS_PAR) ;  /* Fonte "PIMARKERS" */
+    //    fprintf(mPSFile, END_PROLOG) ;
+    /* Aucun format n'est specifie ici ... */
+    fprintf(mPSFile, "$PIDict begin /PIMarkers ff 14 scf sf\n") ;
+    fprintf(mPSFile, "/FState save def\n%%%%EndProlog\n\n") ;
+}
+
+
+
+/*
+ *  PostScript simple...
+ *
+ *
+ */
+PSFile::PSFile(char *FileName,
+	       PIOrientation orientation,
+	       PIPaperSize   paperSize,
+	       float marginX, float marginY)
+ :  mPSFileName (FileName == NULL ? "unnamed.ps" : FileName),
+    Tw(PaperSizeTable[paperSize].width),  /* Format papier utilise */
+    Th(PaperSizeTable[paperSize].height), /*                       */
+    WMargin(marginX),
+    HMargin(marginY),
+    isEPS(0),
+    scale(0.),
+    PageCounter(0),  /* Fichier vide */
+    FileEmpty(1),    /*              */
+    currentPage(NULL),
+    currentBloc(NULL),
+    mDrawColor(PI_Black),
+    mFillColor(PI_Black),
+    mFontAtt(PI_RomanFont),
+    mFontSize(PI_NormalSizeFont),
+    mLineAtt(PI_NormalLine),
+    mMarker(PI_DotMarker) 
+{
+    char * date = new(char[64]) ; 
+    time_t timer ; 
 
     /* Ouverture du fichier, en mode w+ (tout est ecrase) */
@@ -53,125 +344,16 @@
     }
 
-    /* Initialisations... */
-    mFormat.X0 = 0;  /* Pr le moment ... */
-    mFormat.Y0 = 0;
-    mFormat.orientation = LANDSCAPE;
-    if ( (Tx == 0) || (Ty == 0) ) {
-	mFormat.Tx = PAGE_WIDTH;
-	mFormat.Ty = PAGE_HEIGHT;
-    }
-    else {
-      mFormat.Tx = Tx;
-      mFormat.Ty = Ty;
-    }
-    if ( (Dx == 0) || (Dy == 0) ) {
-	mFormat.Dx = mFormat.Tx;
-	mFormat.Dy = mFormat.Ty;
-    }
-    else {
-      mFormat.Dx = Dx;
-      mFormat.Dy = Dy;
-    }
-    PageCounter  = 0;
-    mDrawColor = PI_Black;
-    mFillColor = PI_Black;
-    mFontAtt   = PI_RomanFont;
-    mFontSize  = PI_NormalSizeFont;
-    mLineAtt   = PI_NormalLine;
-    mMarker    = PI_DotMarker;
-
-    /* Ecriture de l'en tete */
-    WriteHeader();
-}
-
-/*
- * Second constructeur 
- *
- * Extraction d'un bloc ou d'une page
- * d'un fichier deja existant
- *
- */
-//PSFile::PSFile(char * FileName, PSFile *File = NULL , int PageNum = 0, 
-//	       int BlocNum = 0) {
-//
-//    PageList::iterator PIt;
-//    char *buffer;
-//
-//    if ( (File == NULL) || (PageNum == 0) ) {
-//	fprintf(stderr, "PSFile::PSFile : args incorrects\n");
-//	return;
-//    }
-//
-// 
-//    if ( FileName != NULL ) {
-//	mPSFileName = new ( char[strlen(FileName)+1] );
-//	strcpy(mPSFileName, FileName);
-//    }
-//    else {
-//	mPSFileName = new ( char[11] );
-//	strncpy(mPSFileName, "unnamed.ps", 11);
-//    }
-//
-//
-//    if ( PageCounter >= PageNum  ) {
-//	for(PIt = (File)->mPageList.begin(); PIt < (File)->mPageList.end(); 
-//	    PIt++);
-//	PIt--;
-//    }
-//    else {
-//	fprintf(stderr, "Page %d inexistante\n", PageNum);
-//	return;
-//    }
-//
-//    if (BlocNum != 0) {
-//	if ( (*PIt).BlocCounter >= BlocNum ) {
-//	    for(BIt=(*PIt).mBlocList.begin();PIt<(*PIt).mBlocList.end();BIt++);
-//	    BIt--;
-//	}
-//	else {
-//	    fprintf(stderr,"Bloc %d, (Page %d) inexistant\n",BlocNum,PageNum);
-//	    return;
-//	}
-//    }
-//
-//    if ( (mPSFile = fopen(FileName, "w+")) == NULL){
-//	  perror (FileName);
-//	  return;
-//    }
-//
-//   mFormat.X0 = 0;
-//    mFormat.Y0 = 0;
-//   mFormat.orientation = PORTRAIT;
-//    if ( (Tx == 0) || (Ty == 0) ) {
-//	mFormat.Tx = PAGE_WIDTH;
-//	mFormat.Ty = PAGE_HEIGHT;
-//    }
-//    if ( (Dx == 0) || (Dy == 0) ) {
-//	mFormat.Dx = mFormat.Tx;
-//	mFormat.Dy = mFormat.Ty;
-//    }
-//    PageCounter  = 0;
-//    mDrawColor = PI_Black;
-//    mFillColor = PI_Black;
-//    mFontAtt   = PI_RomanFont;
-//    mFontSize  = PI_NormalSizeFont;
-//    mLineAtt   = PI_NormalLine;
-//    mMarker    = PI_DotMarker;
-//
-//    WriteHeader();
-//    WriteNewPage(&(*PIt));
-//    if(BlocNum != 0)
-//	WriteNewBloc(&(*BIt));
-//
-//    PSScan(PageNum, BlocNum, off_t limites[2]);
-//    
-//
-//    
-//    buffer = (char*)malloc(BUFSZ*sizeof(char));
-//    
-//    return;
-//}
-
-
+    /* Format et orientation */
+
+    /* Ecriture du Header  */
+    fprintf(mPSFile, "%%!PS-Adobe-2.0\n") ;
+    time(&timer) ; 
+    date = ctime(&timer) ; 
+    fprintf(mPSFile, HEADER, mPSFileName, date) ; /* titre, date etc... */
+    fprintf(mPSFile, PIDICT, PIDICT_PAR) ;        /* Dictionnaire */
+    fprintf(mPSFile, PIMARKERS, PIMARKERS_PAR) ;  /* Fonte "PIMARKERS" */
+    fprintf(mPSFile, "$PIDict begin /PIMarkers ff 14 scf sf\n") ;
+    fprintf(mPSFile, "/FState save def\n%%%%EndProlog\n\n") ;
+}
 
 
@@ -181,18 +363,18 @@
  */
 PSFile::~PSFile () {
-    extern int FileEmpty;
-    extern int BlocActive;
-    extern int PageActive;
 
     /* On ferme tout ce qui ne l'est pas */
-    if (BlocActive) PSFile::EndBloc();
-    if (PageActive) PSFile::EndPage();
+    if (currentBloc) PSFile::EndBloc();
+    if (currentPage) PSFile::EndPage();
 
     /* Si le fichier est vide, on le detruit */
     if (FileEmpty) remove(mPSFileName);
 
-    /* Sinon, on ecrit le "Trailer" et on ferme */
+    /* On ecrit le "Trailer" et on ferme */
     else {
-	WriteTrailer();
+	/* On restore l'etat initial */
+	fprintf(mPSFile,"FState restore\n") ;
+	fprintf(mPSFile, "%%%%Trailer\n%%%%Pages: %d\n%%%%EOF\n", 
+		PageCounter) ;
 	fclose (mPSFile);
     }
@@ -205,17 +387,4 @@
 }
 
-Format *PSFile::GetFormat() {
-
-    Format *form = (Format*)malloc(sizeof(Format));
-
-    form->X0 = mFormat.X0;
-    form->Y0 = mFormat.Y0;
-    form->Tx = mFormat.Tx;
-    form->Ty = mFormat.Ty;
-    form->Dx = mFormat.Dx;
-    form->Dy = mFormat.Dy;
-    form->orientation = mFormat.orientation;
-    return(form);
-}
 
 char* PSFile::GetFileName() {
@@ -254,34 +423,113 @@
 }
 
-void  PSFile::NewPage(float Dx, float Dy, int orient) {
-
-    extern int PageActive;
-    extern int PageEmpty;
-    Page   mNewPage;
+void  PSFile::NewPage(float Dx, float Dy, PIOrientation orientation) {
+
+float  tw, th; /* largeur & hauteur corrigees des marges */
 
     /* On ferme ce qui doit l'etre ... */
-    if (PageActive) PSFile::EndPage();
-
-    mNewPage.num = ++PageCounter;
-    mNewPage.BlocCounter = 0;
-    mNewPage.format.X0 = 0;
-    mNewPage.format.Y0 = 0;
-    mNewPage.format.Tx = mFormat.Tx;
-    mNewPage.format.Ty = mFormat.Ty;
-    mNewPage.format.Dx = Dx;
-    mNewPage.format.Dy = Dy;
-    mNewPage.format.orientation = orient;
-
-    /* On enregistre la position du debut --> AVANT D'ECRIRE */
-    mNewPage.offset.begin  = ftell(mPSFile);
-
-    /* On met a jour le fichier */
-    WriteNewPage(&mNewPage);
-
-    /* On ajoute cette nouvelle page a la liste des pages du fichier */
-    mPageList.push_back(mNewPage);
-
-    PageActive = 1;
-    PageEmpty  = 1;
+    if (currentPage) PSFile::EndPage();
+
+    currentPage = new (Page) ; 
+
+    /* Initialisations */
+    currentPage->num = ++PageCounter;
+    currentPage->BlocCounter = 0;
+    currentPage->Dx = Dx;
+    currentPage->Dy = Dy;
+    currentPage->orientation = orientation ;
+
+    /* Position du debut AVANT D'ECRIRE! */
+    currentPage->begin  = ftell(mPSFile);
+
+    /* On ecrit dans le fichier */
+    fprintf(mPSFile, "%%%%Page: %d %d\n", PageCounter, PageCounter) ;
+    fprintf(mPSFile, "/PState save def 1 -1 scale\n");
+
+    /* 
+     *  Si eps : Portrait || Auto == on laisse tel que
+     *           Landscape == on tourne de -90 degres
+     */
+    if(isEPS) {
+	if( (orientation == PI_Portrait) || (orientation == PI_Auto) )
+	    fprintf(mPSFile,
+		    "%.2f %.2f %.2f %.2f %.2f %.2f newref\n",
+		    Dx, Dy, Dx*scale, Dy*scale, 0., -Dy*scale);
+	else
+	    if(orientation==PI_Landscape)
+		fprintf(mPSFile, 
+			"-90 rotate %.2f %.2f %.2f %.2f %.2f %.2f newref\n",
+			Dx, Dy, Dx*scale, Dy*scale, 0., 0.);
+	    else
+		fprintf(stderr, "Orientation Error ; Page : %d\n",
+			currentPage->num) ; 
+    /* 
+     * On specifie la bb 
+     * (Si non encore fait par un appel precedent a NewPage() ) 
+     */
+	if(boundingBox) {
+	    currentPage->tmp = ftell(mPSFile) ;
+	    fseek(mPSFile,boundingBox,SEEK_SET) ;
+	    if( (orientation == PI_Portrait) || (orientation == PI_Auto) )
+		fprintf(mPSFile, "%d %d %d %d", 0, 0, 
+			(int)(Dx*scale), (int)(Dy*scale) ) ; 
+	    else
+		fprintf(mPSFile, "%d %d %d %d", 0, 0, 
+			(int)(Dy*scale), (int)(Dx*scale) ) ;
+	    fseek(mPSFile,currentPage->tmp,SEEK_SET) ;
+	    boundingBox = 0 ; 
+	} /* BB */
+    } /* EPS */
+    /*
+     * Si ps : 
+     *   - soustraction marges --> rectangle utile.
+     *   - Si PI_Auto : On fait au mieux pour minimiser le 
+     *      redimensionnement...
+     *   - Si PI_Portrait, on ne fait rien, sauf 
+     *      peut-etre un redimensionnement pour rentrer dans les marges
+     *   - Si PI_Landscape, on tourne de -90 degres.
+     */
+    else {
+	/* Eviter image reduite a un point...ou moins... */
+	if((tw = Tw - 2*WMargin) < (Tw/10)) {
+	    WMargin = (0.45)*Tw ;
+	    tw = Tw/10;
+	}
+	if((th = Th - 2*HMargin)< (Th/10)) {
+	    HMargin = (0.45)*Th ;
+	    th = Th/10;
+	}
+	/* Portrait ou Landscape ? */
+	if(orientation == PI_Auto) 
+	    if( ((tw < th) && (Dx < Dy)) ||
+		((tw > th) && (Dx > Dy) )) 
+		currentPage->orientation = PI_Portrait ;
+	    else 
+		currentPage->orientation = PI_Landscape ;
+
+	if(currentPage->orientation == PI_Portrait) {
+	    if( (tw/Dx) < (th/Dy) ) 
+		scale = tw/Dx ;
+	    else 
+		scale = th/Dy;
+	    fprintf(mPSFile, 
+		    "%.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n",
+		    Dx, Dy, 
+		    Dx*scale, Dy*scale, 
+		    0.5*(Tw-tw), -0.5*(Th+th)) ;
+	}
+	if(currentPage->orientation == PI_Landscape) {
+	    /* Idem avec X<->Y */
+	    if( (th/Dx) < (th/Dy) ) 
+		scale = th/Dx;
+	    else
+		scale = tw/Dy ;
+	    fprintf(mPSFile,
+	       "-90 rotate %.2f %.2f %.2f cm %.2f cm %.2f cm %.2f cm newref\n",
+	       Dx, Dy,
+	       Dx*scale, Dy*scale, 
+	       0.5*(Th-th), 0.5*(Tw-tw));
+	}
+    } /* End if .ps */
+currentPage->tmp = ftell(mPSFile);
 }
 
@@ -290,39 +538,26 @@
 void  PSFile::EndPage() {
 
-    extern int PageActive;
-    extern int BlocActive;
-    extern int PageEmpty;
-    extern int FileEmpty;
-    PageList::iterator it;
-
     /* Si rien a fermer, on s'en va */
-    if ( ! PageActive ) return;
+    if ( ! currentPage ) return;
 
     /* Si un bloc non ferme, on appelle EndBloc */
-    if (BlocActive) PSFile::EndBloc();
+    if ( currentBloc ) PSFile::EndBloc();
     
     /* Si la page est vide, on la detruit */
-    if (PageEmpty) {
-	it = mPageList.end(); it--;
-	/* Si 1 seule page ds fichier, retour au debut */
-	if ( it == mPageList.begin() )
-	    fseek(mPSFile, (*it).offset.begin, SEEK_SET);
-	/* Sinon, on retourne a la fin de la page precedente */
-	else {
-	    it--;
-	    fseek(mPSFile, (*it).offset.end, SEEK_SET);
-	    it++;
-	}
-	mPageList.erase(it);
+    if (currentPage->tmp == ftell(mPSFile)) {
+	fseek(mPSFile, currentPage->begin, SEEK_SET);
+	delete(currentPage) ;
 	PageCounter--;
     }
-    /* Sinon, Ok, on met a jour le fichier  */
+    /* Sinon, fin page + empilage */
     else {
-	it = mPageList.end(); it--;
-	(*it).offset.end = ftell(mPSFile);
-	WriteEndPage(&(*it));
+	//	it = mPageList.end(); it--;
+	fprintf(mPSFile,"PState restore  showpage\n");
+	fprintf(mPSFile,"%%>EndPage %d\n\n\n", currentPage->num);
+	currentPage->end = ftell(mPSFile);
+	mPageList.push_back(*currentPage); /* Pourquoi PageList ? */
 	FileEmpty = 0;
     }
-    PageActive = 0;
+    currentPage = NULL;
 }
 
@@ -330,85 +565,59 @@
 void  PSFile::NewBloc(float x0, float y0, float Tx, float Ty,
 			      float Dx, float Dy){
-    extern int BlocActive;
-    extern int PageActive;
-    extern int BlocEmpty;
-    Bloc   mNewBloc;
-    PageList::iterator it;
 
     /* Si pas de page, on s'en va */
-    if (!PageActive) return;
+    if ( ! currentPage ) return;
 
     /* On ferme le bloc precedent (Pas de Bloc-gigognes ! ) */
-    if (BlocActive) PSFile::EndBloc();
-
-    it = mPageList.end(); it --;
-    /* On remplit mNewBloc */
-    mNewBloc.num = ++(*it).BlocCounter;
-    mNewBloc.format.X0 = x0;
-    mNewBloc.format.Y0 = y0;
-    mNewBloc.format.Tx = Tx;
-    mNewBloc.format.Ty = Ty;
-    mNewBloc.format.Dx = Dx;
-    mNewBloc.format.Dy = Dy;
-    mNewBloc.format.orientation = 0;    /* Pr l'inst, blk non orient */
-    mNewBloc.offset.begin = ftell(mPSFile);
+    if (currentBloc) PSFile::EndBloc();
+
+    currentBloc = new (Bloc) ; 
+    /* On remplit currentBloc */
+    currentBloc->num = ++(currentPage->BlocCounter);
+    currentBloc->X0 = x0;
+    currentBloc->Y0 = y0;
+    currentBloc->Tx = Tx;
+    currentBloc->Ty = Ty;
+    currentBloc->Dx = Dx;
+    currentBloc->Dy = Dy;
+    currentBloc->begin = ftell(mPSFile);
 
     /* On met a jour le fichier */
-    WriteNewBloc(&mNewBloc);
-
-    /* On met a jour la liste des blocs */
-    (*it).mBlocList.push_back(mNewBloc);
-
-    BlocActive = 1;
-    BlocEmpty  = 1;
+    fprintf(mPSFile, "%%>BeginBloc %d\n", currentBloc->num);
+    fprintf(mPSFile, "%.2f %.2f %.2f Ux %.2f Uy %.2f Ux %.2f Uy NewBloc\n",
+	    currentBloc->Dx, currentBloc->Dy,
+	    currentBloc->Tx, currentBloc->Ty,
+	    currentBloc->X0, currentBloc->Y0);
+    currentBloc->tmp = ftell(mPSFile) ;
 }
 
 
 void  PSFile::EndBloc() {
-    extern int BlocActive;
-    extern int BlocEmpty;
-    extern int PageEmpty;
-    PageList::iterator  PIt;
-    BlocList::iterator  BIt;
 
     /* On verifie qu'un bloc ouvert existe bien */
-    if ( ! BlocActive ) return;
+    if ( ! currentBloc ) return;
 
     /* Si le bloc est vide, on le detruit */
-    if (BlocEmpty) {
-	PIt = mPageList.end(); PIt--;
-	BIt = (*PIt).mBlocList.end(); BIt--;
-	/* Si 1 seul bloc --> debut */
-	if ( BIt == (*PIt).mBlocList.begin()) {
-	    fseek(mPSFile,(*BIt).offset.begin, SEEK_SET);
-	}
-	/* Sinon, --> fin du bloc precedent */
-	else {
-	    BIt--;
-	    fseek(mPSFile, (*BIt).offset.end, SEEK_SET);
-	    BIt++;
-	}   
-	(*PIt).mBlocList.erase(BIt);
-	(*PIt).BlocCounter--;
+    if (currentBloc->tmp == ftell(mPSFile)) {
+	fseek(mPSFile, currentBloc->begin, SEEK_SET) ; 
+	currentPage->BlocCounter-- ; 
     }
     /* Sinon, Ok met a jour le fichier */
-    else {
-	PIt = mPageList.end(); PIt--;
-	BIt = (*PIt).mBlocList.end(); BIt--;
-	(*BIt).offset.end = ftell(mPSFile);
-	WriteEndBloc(&(*BIt));
-	PageEmpty = 0;
-    }
-    
-    BlocActive = 0;
+    else { 
+	fprintf(mPSFile, "EndBloc\n"); 
+	fprintf(mPSFile, "%%>EndBloc %d\n", currentBloc->num); 
+	currentBloc->end = ftell(mPSFile) ; 
+	currentPage->mBlocList.push_back(*currentBloc) ; 
+	//	PageEmpty = 0; 
+    } 
+    /* Flags */
+    currentBloc = NULL ; 
 }
 
 
 void  PSFile::DrawString  (float x,  float y, char *s, 
-		   PIColors DrawColor, 
-		   PIFontAtt FontAtt, 
-		   int FontSize) {
-    extern int BlocEmpty;
-    extern int PageEmpty;
+			   PIColors DrawColor, 
+			   PIFontAtt FontAtt, 
+			   int FontSize) {
     int change = 0;
 
@@ -416,7 +625,6 @@
     if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
 	mDrawColor = DrawColor;
-        WriteSetColor(mDrawColor);
-    }
-
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    }
     /* Choix des fontes */
     if ( (FontAtt != PI_NotDefFontAtt) || (FontAtt != mFontAtt) ) {
@@ -427,10 +635,7 @@
 	change = 1;}
     if (change)
-	WriteSetFont(mFontAtt, mFontSize);
-
-    WriteDrawString(x, y, s);
-
-    BlocEmpty = 0;
-    PageEmpty = 0;
+	fprintf(mPSFile, "F%d %d FS ", mFontAtt, FontSize) ; 
+
+    fprintf(mPSFile, "gs %.2f Ux %.2f Uy m (%s) S gr\n", x, y, s) ; 
 }
 
@@ -439,11 +644,9 @@
 		   PIColors DrawColor,
 		   PILineAtt LineAtt) {
-    extern int BlocEmpty;
-    extern int PageEmpty;
 
     /* Line Att */
     if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
         mLineAtt = LineAtt;
-	WriteSetLineWidth(mLineAtt);
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
     }
 
@@ -451,26 +654,22 @@
     if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
 	mDrawColor = DrawColor;
-	WriteSetColor(mDrawColor);
+	fprintf(mPSFile, "C%d ", mDrawColor);
     }
 
     /* Dessin */
-    WriteDrawLine(x1, y1, x2, y2);
-
-    BlocEmpty = 0;
-    PageEmpty = 0;
-}
-
-
-
-void  PSFile::DrawBox     (float x0, float y0, float Tx, float Ty, 
-		   PIColors  DrawColor,
-		   PILineAtt LineAtt) {
-    extern int BlocEmpty;
-    extern int PageEmpty;
+    fprintf(mPSFile, "n %.2f Ux %.2f Uy m %.2f Ux %.2f Uy l s\n",
+	    x1, y1, x2, y2) ;
+}
+
+
+
+void  PSFile::DrawBox(float x0, float y0, float Tx, float Ty, 
+		      PIColors  DrawColor,
+		      PILineAtt LineAtt) {
 
     /* Changement couleurs ? */
     if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
 	mDrawColor = DrawColor;
-	WriteSetColor(mDrawColor);
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
     }
 
@@ -478,28 +677,22 @@
     if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
         mLineAtt = LineAtt;
-	WriteSetLineWidth(mLineAtt);
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
     }
 
     /* On dessine */
-    WriteDrawBox(x0, y0, Tx, Ty);
-    
-    /* Le fichier n'est plus vide */
-    BlocEmpty = 0;
-    PageEmpty = 0;
-}
-
-
-void  PSFile::DrawFBox    (float x0, float y0, float Tx, float Ty, 
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy box s gr\n",
+	    Tx, Ty, x0, y0) ; 
+}
+
+
+void  PSFile::DrawFBox(float x0, float y0, float Tx, float Ty, 
 		   PIColors DrawColor,
 		   PIColors FillColor, 
 		   PILineAtt LineAtt) {
-    extern int BlocEmpty;
-    extern int PageEmpty;
-
 
     /* Line Att */
     if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
         mLineAtt = LineAtt;
-	WriteSetLineWidth(mLineAtt);
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
     }
 
@@ -507,30 +700,25 @@
     if ( (FillColor != PI_NotDefColor) || (FillColor != mFillColor) )
 	mFillColor = FillColor;
-    WriteSetColor(mFillColor);
-    WriteDrawFBox(x0, y0, Tx, Ty);
-    WriteSetColor(mDrawColor);
-
+    fprintf(mPSFile, "C%d ", mFillColor) ; 
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy box f gr\n",
+	    Tx, Ty, x0, y0) ; 
+    
     /* Dessin du contour (s'il y a lieu) */
-    if ( (DrawColor != PI_NotDefColor) && (FillColor != DrawColor) ) {
+    if ( (DrawColor != PI_NotDefColor) && (FillColor != DrawColor) )
 	mDrawColor = DrawColor;
-	WriteSetColor(DrawColor);
-	WriteDrawBox(x0, y0, Tx, Ty);
-    }
-    /* Le fichier n'est plus vide */
-    BlocEmpty = 0;
-    PageEmpty = 0;
+    fprintf(mPSFile, "C%d ", mDrawColor) ; 
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy box s gr\n",
+	    Tx, Ty, x0, y0) ;
 }
 
 
 void  PSFile::DrawCircle  (float x0, float y0, float r, 
-		   PIColors DrawColor,
-		   PILineAtt LineAtt) {
-    extern int BlocEmpty;
-    extern int PageEmpty;
+			   PIColors DrawColor,
+			   PILineAtt LineAtt) {
 
     /* Couleurs */
     if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
 	mDrawColor = DrawColor;
-	WriteSetColor(DrawColor);
+	fprintf(mPSFile, "C%d ", mDrawColor); 
     }
 
@@ -538,12 +726,10 @@
     if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
         mLineAtt = LineAtt;
-	WriteSetLineWidth(mLineAtt);
+	fprintf(mPSFile, "%d slw ", mLineAtt); 
     }
 
     /* Dessin */
-    WriteDrawCircle(x0, y0, r);
-
-    BlocEmpty = 0;
-    PageEmpty = 0;
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy 0 360 ellipse s gr\n",
+	    x0, y0, r, r) ;
 }
 
@@ -553,11 +739,9 @@
 		   PIColors FillColor, 
 		   PILineAtt LineAtt) {
-    extern int BlocEmpty;
-    extern int PageEmpty;
 
     /* Line Att */
     if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
         mLineAtt = LineAtt;
-	WriteSetLineWidth(mLineAtt);
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
     }
 
@@ -565,16 +749,18 @@
     if ( (FillColor != PI_NotDefColor) || (FillColor != mFillColor) ){
 	mFillColor = FillColor;
-	WriteSetColor(FillColor);
-    }
-    WriteDrawFCircle(x0, y0, r);
+	fprintf(mPSFile, "C%d ", mFillColor) ;
+    }
+    fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy \
+                      0 360 ellipse f gr\n",
+	    x0, y0, r, r);
+    fprintf(mPSFile, "C%d ", mDrawColor) ;
 
     /* Dessin du contour (s'il y a lieu) */
     if ( (DrawColor != PI_NotDefColor) && (FillColor != DrawColor) ) {
 	mDrawColor = DrawColor;
-	WriteSetColor(DrawColor);
-	WriteDrawCircle(x0, y0, r);
-    }    
-    BlocEmpty = 0;
-    PageEmpty = 0;
+	fprintf(mPSFile, "C%d ", mDrawColor); 
+	fprintf(mPSFile, "gs n %.2f Ux %.2f Uy %.2f Ux %.2f Uy 0 360 ellipse s gr\n",
+		x0, y0, r, r) ;
+    }
 }
 
@@ -583,12 +769,9 @@
 		   PIColors DrawColor, 
 		   PILineAtt LineAtt) {
-    extern int BlocEmpty;
-    extern int PageEmpty;
-    //    int change = 0;
 
     /* Line Att */
     if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
         mLineAtt = LineAtt;
-	WriteSetLineWidth(mLineAtt);
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
     }
 
@@ -596,12 +779,13 @@
     if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
 	mDrawColor = DrawColor;
-	WriteSetColor(DrawColor);
+	fprintf(mPSFile, "C%d ", mDrawColor) ;
     }
     
     /* On dessine ; ici*/
-    WriteDrawPolygon (x, y, n);
-    
-    BlocEmpty = 0;
-    PageEmpty = 0;
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m\n", x[0], y[0]);
+    for(int i = 0; i<n; i++) 
+	fprintf(mPSFile, "%.2f Ux %.2f Uy %.2f Ux %.2f Uy l\n",
+		x[i+1], y[i+1], x[i], y[i]);
+    fprintf(mPSFile, "c s\n");
 }
 
@@ -612,29 +796,30 @@
 		   PILineAtt LineAtt) {
 
-    extern int BlocEmpty;
-    extern int PageEmpty;
-
     /* Line Att */
     if ( (LineAtt != PI_NotDefLineAtt) || (LineAtt != mLineAtt) ) {
         mLineAtt = LineAtt;
-	WriteSetLineWidth(mLineAtt);
+	fprintf(mPSFile, "%d slw ", mLineAtt) ; 
     }
 
     /* Dessin du fond... */
-    if ( (FillColor != PI_NotDefColor) || (FillColor != mFillColor) ) {
+    if ( (FillColor != PI_NotDefColor) || (FillColor != mFillColor) ) 
 	mFillColor = FillColor;
-	WriteSetColor(FillColor);
-    }
-    WriteDrawFPolygon(x, y, n);
+    fprintf(mPSFile, "C%d ", mFillColor) ;
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m\n", x[0], y[0]);
+    int i;
+    for(i = 0; i<n; i++) 
+	fprintf(mPSFile, "%.2f Ux %.2f Uy %.2f Ux %.2f Uy l\n",
+		x[i+1], y[i+1], x[i], y[i]);
+    fprintf(mPSFile, "c f\n");
 
     /* ...puis du contour (s'il y a lieu) */
-    if ( (DrawColor != PI_NotDefColor) && (DrawColor != FillColor) ) {
+    if ( (DrawColor != PI_NotDefColor) && (DrawColor != FillColor) )
 	mDrawColor = DrawColor;
-	WriteSetColor(DrawColor);
-	WriteDrawPolygon(x, y, n);
-    }
-
-    BlocEmpty = 0;
-    PageEmpty = 0;
+    fprintf(mPSFile, "C%d ", mDrawColor) ;
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m\n", x[0], y[0]);
+    for(i = 0; i<n; i++) 
+	fprintf(mPSFile, "%.2f Ux %.2f Uy %.2f Ux %.2f Uy l\n",
+		x[i+1], y[i+1], x[i], y[i]);
+    fprintf(mPSFile, "c s\n");
 }
 
@@ -642,14 +827,11 @@
 
 void  PSFile::DrawMarker  (float x0, float y0,
-		   PIMarker MrkType,   
-		   PIColors DrawColor) {
-    extern int BlocEmpty;
-    extern int PageEmpty;
-
-
+			   PIMarker MrkType,   
+			   PIColors DrawColor,
+			   int MarkerSize) {
     /* Couleurs */
     if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
 	mDrawColor = DrawColor;
-	WriteSetColor(mDrawColor);
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
     }
 
@@ -658,22 +840,25 @@
 	mMarker = MrkType;
 
+    if(MarkerSize != mMarkerSize) {
+	mMarkerSize = MarkerSize ;
+	fprintf(mPSFile, "/PIMarkers ff %d scf sf\n", mMarkerSize) ; 
+    }
     /* Dessin */
-    WriteDrawMarker(x0, y0);
-
-    BlocEmpty = 0;
-    PageEmpty = 0;
-}
-
-
+    fprintf(mPSFile, "%.2f Ux %.2f Uy m (\\%#o) show\n", x0, y0, mMarker) ;
+
+}
+
+/*
+ * Pas d'options pour specifier la taille des Markers ?
+ *
+ */
 void  PSFile::DrawMarkers (float *x0, float *y0, int n,
-		   PIMarker MrkType,
-		   PIColors DrawColor) {
-    extern int BlocEmpty;
-    extern int PageEmpty;
-
+			   PIMarker MrkType,
+			   PIColors DrawColor,
+			   int MarkerSize) {
     /* Couleurs */
     if ( (DrawColor != PI_NotDefColor) || (DrawColor != mDrawColor) ) {
 	mDrawColor = DrawColor;
-	WriteSetColor(mDrawColor);
+	fprintf(mPSFile, "C%d ", mDrawColor) ; 
     }    
 
@@ -682,9 +867,11 @@
 	mMarker = MrkType;
 
+    if(MarkerSize != mMarkerSize) {
+	mMarkerSize = MarkerSize ;
+	fprintf(mPSFile, "/PIMarkers ff %d scf sf\n", mMarkerSize) ; 
+    }
     /* Dessin */
-    WriteDrawMarkers(x0, y0, n);
-
-    BlocEmpty = 0;
-    PageEmpty = 0;
+    for(int i = 0; i<n; i++)
+	fprintf(mPSFile, "%.2f Ux %.2f Uy m (\\%#o) show\n", x0[i], y0[i], mMarker) ; 
 }
 
@@ -694,15 +881,41 @@
 		   PIColorMap *mMap) {
 
-    extern int BlocEmpty;
-    extern int PageEmpty;
-
-    WriteImage(x0, y0, Tx, Ty, Nx, Ny, Pict,mMap);
-
-    BlocEmpty = 0;
-    PageEmpty = 0;
+    int i, j;
+
+    /* Buffers PostScript */
+    fprintf(mPSFile, "/Taille %d def\n", Nx);
+    fprintf(mPSFile, "/ImStr Taille string def\n");
+    fprintf(mPSFile, "/RGBStr Taille 3  mul string def\n");
+
+    /* Ecriture ColorMap */
+    fprintf(mPSFile, "/ColorMap %02d array def\n", mMap->NCol() );
+    for(i = 0; i < mMap->NCol(); i++) {
+	fprintf(mPSFile, "ColorMap %d [16#%02X 16#%02X 16#%02X] put\n",
+		i,
+		(int)(mMap->GetColor(i).red/256),
+		(int)(mMap->GetColor(i).green/256),
+		(int)(mMap->GetColor(i).blue/256));
+    }
+    /* Emplacement de l'image */
+    fprintf(mPSFile, "gs %.2f  %.2f  tr %.2f Ux %.2f Uy sc\n", x0, y0, Tx, Ty);
+    /* Nbr pix-X, Nbr pix-Y bits/pixels */
+    fprintf(mPSFile, "%d %d 8\n", Nx, Ny);
+    /* Matrice de passage */
+    fprintf(mPSFile, "[%d 0 0 %d 0 0]", Nx, Ny);
+    /* Fonction colorimage */
+    fprintf(mPSFile, "{currentfile ImStr readhexstring pop GetRGB}\
+false 3 colorimage\n\n");
+    /* Data */
+    for(i = 0; i < Ny; i++) {
+	for(j = 0; j<Nx-1; j++ )
+	    fprintf(mPSFile, "%02X", Pict[i*Nx+j]);
+    fprintf(mPSFile, "%02X\n", Pict[i*Nx+j]);
+    }
+    /* Un petit grestore ...*/
+    fprintf(mPSFile, "gr\n");
 }
 
 /* 
- *  Une fonction de conversion qui sert une fois
+ *  Conversion
  *
  */
@@ -712,9 +925,2 @@
 }
 
-
-    /* Logique de controle */
-    /* static */ int FileEmpty = 1;
-    /* static */ int PageEmpty;
-    /* static */ int BlocEmpty;
-    /* static */ int BlocActive;
-    /* static */ int PageActive;
Index: /trunk/SophyaPI/PI/psfile.h
===================================================================
--- /trunk/SophyaPI/PI/psfile.h	(revision 43)
+++ /trunk/SophyaPI/PI/psfile.h	(revision 44)
@@ -12,4 +12,7 @@
  *        Au depart, 1UC == 1cm 
  *     - Les reperes sont orientes a la maniere XWindow
+ * 
+ *  17/02/97 : modification des constructeurs(1-->eps,2-->ps)
+ *             ajout du type enum orientation
  *
  */
@@ -22,4 +25,5 @@
 #endif
 #include "pisysdep.h"
+//#include "piinclude.h"
 
 #include PIBWDG_H      // Types enumeres repris de Peida:PIFontSize...
@@ -29,36 +33,33 @@
 
 
-/* 
- *  Unique format actuellement gere : A4
- *
- */
-enum PIPaperSizes { PI_A3 = 0, PI_A4 = 1, PI_A5 = 2, PI_NotDef = -1};
-
-#define PAGE_WIDTH   21.0   /* == 595 points */
-#define PAGE_HEIGHT  29.7   /* == 842 points */
-
-#define PORTRAIT  1
-#define LANDSCAPE 0
+
+/*
+ *#define PAGE_WIDTH   21.0    == 595 points 
+ *#define PAGE_HEIGHT  29.7    == 842 points 
+ *#define PORTRAIT  1
+ *#define LANDSCAPE 0
+ */
 
 
 
 /* Valable pour une page, ou un bloc */
-typedef struct {
-    float X0;         /* Coordonnes sommet NO  */
-    float Y0;         /*  en unites courantes  */
-    float Tx;         /* Format                */
-    float Ty;         /*  en unites courantes  */
-    float Dx;         /* Coord sommet SE       */
-    float Dy;         /*  en unites courantes  */
-    int orientation;  /* LANDSCAPE OU PORTRAIT */
-} Format;
-
-
-typedef struct{
-    char *Name;
-    int  Tx;     /* En 1/72e de pouce  !!  */
-    int  Ty;     /* unite naturelle de ps  */
-} PIMedia;
-
+/*typedef struct {
+ *  float X0;          Coordonnes sommet NO  
+ *  float Y0;           en unites courantes  
+ *  float Tx;          Format                
+ *  float Ty;           en unites courantes  
+ *  float Dx;          Coord sommet SE       
+ *  float Dy;           en unites courantes  
+ *  int orientation;   LANDSCAPE OU PORTRAIT 
+ *} Format;
+ */
+
+/*
+ *typedef struct{
+ *    char *Name;
+ *    int  Tx;     En 1/72e de pouce  !! 
+ *    int  Ty;     unite naturelle de ps 
+ *} PIMedia;
+ */
 
 
@@ -67,9 +68,10 @@
 
 public:
-
-		  PSFile (char * FileName, float Tx = 0, float Ty = 0,
-			  float Dx = 0, float Dy = 0);
-/*		  PSFile (PSFile *File, int PageNum, int BlocNum);*/
-/*		  PSFile (char * FileName, int PageNum, int BlocNum);*/
+    /* Production fichier eps */
+    PSFile (char * FileName, float sc = 1.0);
+    /* Production fichier ps  */
+    PSFile (char * FileName, PIOrientation orientation, 
+	    PIPaperSize paperSize= PI_A4, 
+	    float marginX = 1.0, float marginY = 1.0 ) ;
 
     virtual      ~PSFile();
@@ -79,11 +81,6 @@
 
 
-    /* A changer ?
-     * Pourrait introduire des incompatibilites
-     * en cas de chgt sur la struct format ?
-     */
-    virtual Format* GetFormat();
-
-    /*Attributs graphiques */
+    /*    virtual Format* GetFormat(); */
+    /* Attributs graphiques */
     virtual PIColors    GetDrawColor();
     virtual PIColors    GetFillColor();
@@ -93,5 +90,5 @@
     virtual PIMarker    GetMarker();
 
-    virtual void  NewPage(float Dx, float Dy, int orientation);
+    virtual void  NewPage(float Dx, float Dy, PIOrientation orientation);
     virtual void  EndPage();
     virtual void  NewBloc(float x0, float y0, float Tx, float Ty,
@@ -130,8 +127,10 @@
     virtual void  DrawMarker  (float x0, float y0, 
 			       PIMarker MrkType    = PI_NotDefMarker, 
-			       PIColors DrawColor  = PI_NotDefColor);
+			       PIColors DrawColor  = PI_NotDefColor,
+			       int MarkerSize=14);
     virtual void  DrawMarkers (float *x0, float *y0, int n,
 			       PIMarker MrkType    = PI_NotDefMarker,
-			       PIColors DrawColor  = PI_NotDefColor); 
+			       PIColors DrawColor  = PI_NotDefColor,
+			       int MarkerSize=14); 
 
     virtual void  Image(float x0, float y0, float Tx, float Ty,
@@ -140,23 +139,20 @@
 			PIColorMap *mColorMap);
 
-
-
-
-
-
-
-    typedef struct {
-	off_t begin;
-	off_t end;
-    } Offset;
-    
+#ifndef __DECCXX
+private:
+#endif
+
+
     /* Blocs */
     typedef struct {
 	int    num;
 	char*  label;
-	Format format;
-	Offset offset;
-    } Bloc;
+	float  X0, Y0;            /* coordonnees sommet NO */
+	float  Tx, Ty;            /* Format */
+	float  Dx, Dy;            /* Repere utilisateur */
+	long  begin,end,tmp;   /* offsets dans le fichier */
+    } Bloc ;
     typedef list<Bloc> BlocList;  /* STL */
+
 
     /* Pages */
@@ -164,56 +160,41 @@
 	int num;
 	int BlocCounter;
-	Format format;
-	Offset offset;
-	BlocList mBlocList;       /* Page == Liste de blocs */
-    } Page;
+	float Dx,Dy;              /* Sommet SE (unites utilisateur) */ 
+	PIOrientation orientation;
+	long  begin, end, tmp;    /* Offsets dans le fichier */
+	BlocList mBlocList;       /* Page == Liste de blocs  */
+    } Page ;
     typedef list<Page> PageList;  /* STL */
 
+#ifdef __DECCXX
 private:
-
-    /* --> Toute la classe */
-    static PSFile** PSFiles;      /* Tableau des PSFiles existants */
-
-    /* --> le fichier */
+#endif
+
+    /* Fichier ps/eps */
     FILE *   mPSFile;
     char *   mPSFileName;
+    float    Tw,Th ;              /* Format, en cm */
+    float    WMargin,HMargin ;    /* Marges minimales */
     int      isEPS;               /* Vrai si PostScript Encapsule */
-    Format   mFormat;             /* Format par defaut */
-    int      PageCounter;         /* Nbre de pages */
-    PageList mPageList;           /* Fichier == Liste de pages */
-
-    /* Attributs graphiques */
+    long     boundingBox;         /* Endroit ou est specifiee la bb */
+    float    scale;               /* boundingbox = Dx*scale ; Dy*scale */
+    PIPaperSize mPaperSize ; 
+    int      PageCounter;         /* nbr pages */
+    int      FileEmpty;
+    Page*    currentPage;        /* Avant empilage */
+    Bloc*    currentBloc;        /* Avant empilage */
+    PageList mPageList;          /* Fichier == Liste de pages */
+
+
+    /* Attributs graphiques, initialises par constructeur */
     enum PIColors    mDrawColor;  /* Couleur de trace courante */
     enum PIColors    mFillColor;  /* Couleur de remplissage courante */
-    enum PIFontAtt   mFontAtt;
-    enum PIFontSize  mFontSize;
+    enum PIFontAtt   mFontAtt; 
+    enum PIFontSize  mFontSize; 
     enum PILineAtt   mLineAtt;    /* Epaisseur d une ligne */
     enum PIMarker    mMarker;     /* Marker courant */
-
-
-    /* Ecriture du PostScript dans le fichier Physique */
-    /* Le code se trouve ds PSDict.cc                  */
-    virtual void  WriteHeader();
-    virtual void  WriteTrailer();
-    virtual void  WriteNewPage(Page *mPage);
-    virtual void  WriteEndPage(Page *mPage);
-    virtual void  WriteNewBloc(Bloc *mBloc);
-    virtual void  WriteEndBloc(Bloc *mBloc);
-    virtual void  WriteDrawString(float x, float y, char* s);
-    virtual void  WriteDrawLine(float x1, float y1, float x2, float y2);
-    virtual void  WriteDrawBox(float x0, float y0, float Tx, float Ty);
-    virtual void  WriteDrawFBox(float x0, float y0, float Tx, float Ty);
-    virtual void  WriteDrawCircle(float x0, float y0, float r);
-    virtual void  WriteDrawFCircle(float x0, float y0, float r);
-    virtual void  WriteDrawPolygon(float *x, float *y, int n);
-    virtual void  WriteDrawFPolygon(float *x, float *y, int n);
-    virtual void  WriteDrawMarker(float x0, float y0);
-    virtual void  WriteDrawMarkers(float *x0, float *y0, int n);
-    virtual void  WriteImage(float x0, float y0, float Tx, float Ty,
-		     int Nx, int Ny, unsigned char *pict, PIColorMap *mColorMap);
-    virtual void  WriteSetColor(PIColors mDrawColor);
-    virtual void  WriteSetFont(PIFontAtt mFontAtt, int mFontSize);
-    virtual void  WriteSetLineWidth(PILineAtt mLineAtt);
-};  /* End class PSFile */
+    int              mMarkerSize; /* Taille (en points) du marker courant */
+} ;
+
 
 #endif/* PSFILE_H_SEEN */
