Index: trunk/SophyaPI/ProgPI/Makefile
===================================================================
--- trunk/SophyaPI/ProgPI/Makefile	(revision 1513)
+++ trunk/SophyaPI/ProgPI/Makefile	(revision 1524)
@@ -17,5 +17,5 @@
 LDLIBS := $(LIBS) $(LDLIBS)
 PROGS = $(EXE)spiapp
- 
+
 all: $(PROGS)
 
@@ -25,8 +25,89 @@
 
 spiapp: $(EXE)spiapp
-	echo echo $@ " done"
-$(EXE)spiapp: $(OBJ)piapp.o $(OBJ)sopiamodule.o $(OBJ)fitsbtadapter.o
+	echo echo $@ " done"	
+$(EXE)spiapp: $(OBJ)piapp.o $(OBJ)sopiamodule.o $(OBJ)fitsbtadapter.o $(OBJ)w2ps.o
 	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@ 
-  
+
+$(OBJ)fitsbtadapter.o: fitsbtadapter.cc \
+ $(INC)machdefs.h \
+ $(INC)nobjmgr.h \
+ $(INC)anydataobj.h \
+ $(INC)ppersist.h \
+ $(INC)pexceptions.h \
+ $(INC)gnumd5.h \
+ $(INC)dvlist.h \
+ $(INC)objfio.h \
+ $(INC)mutyv.h \
+ $(INC)dlftypes.h \
+ $(INC)servnobjm.h \
+ $(INC)pdlmgr.h \
+ $(INC)nomgadapter.h \
+ $(INC)pidrawer.h \
+ $(INC)pibwdggen.h \
+ $(INC)pisysdep.h \
+ $(INC)piwdgx.h \
+ $(INC)piwdggen.h \
+ $(INC)pimsghandler.h \
+ $(INC)picolist.h \
+ $(INC)picmap.h \
+ $(INC)picmapx.h \
+ $(INC)picmapgen.h \
+ $(INC)pigraphx.h \
+ $(INC)pigraphgen.h \
+ $(INC)pifontx.h \
+ $(INC)pifontgen.h \
+ $(INC)pigraphuc.h \
+ $(INC)pievthandler.h \
+ $(INC)psfile.h \
+ $(INC)parradapter.h \
+ $(INC)lut.h \
+ $(INC)ntupintf.h \
+ $(INC)generalfit.h \
+ $(INC)tvector.h \
+ $(INC)tmatrix.h \
+ $(INC)tarray.h \
+ $(INC)basarr.h \
+ $(INC)ndatablock.h \
+ $(INC)utilarr.h \
+ $(INC)generaldata.h \
+ $(INC)poly.h \
+ $(INC)peida.h \
+ $(INC)utils.h \
+ $(INC)perrors.h \
+ $(INC)fmath.h \
+ $(INC)pistdimgapp.h \
+ $(INC)piapplx.h \
+ $(INC)piapplgen.h \
+ $(INC)picontainerx.h \
+ $(INC)picontainergen.h \
+ $(INC)pimenubarx.h \
+ $(INC)pimenubargen.h \
+ $(INC)pimenux.h \
+ $(INC)pimenugen.h \
+ $(INC)picons.h \
+ $(INC)pistdwdgx.h \
+ $(INC)pistdwdggen.h \
+ $(INC)pibwdgx.h \
+ $(INC)pigraphps.h \
+ $(INC)piwindowx.h \
+ $(INC)piwindowgen.h \
+ $(INC)pioptmenux.h \
+ $(INC)pioptmenugen.h \
+ $(INC)pifilechox.h \
+ $(INC)pifilechogen.h \
+ $(INC)piimage.h \
+ $(INC)pipixmapx.h \
+ $(INC)pipixmapgen.h \
+ $(INC)picmapview.h \
+ $(INC)pi3ddrw.h \
+ $(INC)pigraph3d.h \
+ $(INC)piacmd.h \
+ $(INC)pisiadw.h \
+ $(INC)pilistx.h \
+ $(INC)pilistgen.h \
+ $(INC)pistzwin.h \
+ $(INC)piperiodx.h \
+ $(INC)periodic.h \
+ $(INC)fbtntintf.h 
 $(OBJ)piapp.o: piapp.cc $(INC)pistdimgapp.h \
  $(INC)pisysdep.h \
@@ -255,7 +336,5 @@
  $(INC)piscdrawwdg.h \
  $(INC)ctimer.h
-$(OBJ)fitsbtadapter.o: fitsbtadapter.cc \
- $(INC)fbtntintf.h \
- $(INC)machdefs.h \
+$(OBJ)w2ps.o: w2ps.cc $(INC)machdefs.h \
  $(INC)piacmd.h \
  $(INC)dlftypes.h \
@@ -319,12 +398,3 @@
  $(INC)pistzwin.h \
  $(INC)piperiodx.h \
- $(INC)periodic.h \
- $(INC)servnobjm.h \
- $(INC)tvector.h \
- $(INC)tmatrix.h \
- $(INC)tarray.h \
- $(INC)basarr.h \
- $(INC)ndatablock.h \
- $(INC)utilarr.h \
- $(INC)pitvmaad.h \
- $(INC)piscdrawwdg.h \
+ $(INC)periodic.h
Index: trunk/SophyaPI/ProgPI/piapp.cc
===================================================================
--- trunk/SophyaPI/ProgPI/piapp.cc	(revision 1513)
+++ trunk/SophyaPI/ProgPI/piapp.cc	(revision 1524)
@@ -20,4 +20,6 @@
 void fitsbtadapter_init();
 void fitsbtadapter_end();
+void W2PSModule_init();
+void W2PSModule_end();
 }
 
@@ -160,4 +162,6 @@
 // On charge le module de lecture ligne a ligne des Fits BINARY/ASCII tables
 fitsbtadapter_init();
+// On charge le module des commandes de creation de fichier postscript
+W2PSModule_init();
 
 // S'il y a besoin de faire le fichier Help
@@ -234,4 +238,5 @@
 sopiamodule_end();
 fitsbtadapter_end();
+W2PSModule_end();
 
 delete app;
Index: trunk/SophyaPI/ProgPI/programs
===================================================================
--- trunk/SophyaPI/ProgPI/programs	(revision 1513)
+++ trunk/SophyaPI/ProgPI/programs	(revision 1524)
@@ -1,1 +1,1 @@
-spiapp piapp.o sopiamodule.o fitsbtadapter.o
+spiapp piapp.o sopiamodule.o fitsbtadapter.o w2ps.o
Index: trunk/SophyaPI/ProgPI/w2ps.cc
===================================================================
--- trunk/SophyaPI/ProgPI/w2ps.cc	(revision 1524)
+++ trunk/SophyaPI/ProgPI/w2ps.cc	(revision 1524)
@@ -0,0 +1,218 @@
+#include "machdefs.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream.h>
+#include <math.h>
+
+#include <typeinfo>
+
+#include <vector>
+#include <string>
+
+#include "piacmd.h"
+#include "nobjmgr.h"
+#include "pistdimgapp.h"
+
+
+//  Module chargeable ds piapp - Commande de gestion de sortie PS
+
+//  Declaration de la fonction d'activation et de desactivation du module
+extern "C" {
+void W2PSModule_init();
+void W2PSModule_end();
+}
+
+
+//  Une classe commande-executor, permettant d'enregistrer de 
+//  nouvelles commandes a piapp
+class W2PSModuleExecutor : public CmdExecutor {
+public:
+                W2PSModuleExecutor();
+  virtual       ~W2PSModuleExecutor();
+  // Execute s'occupe de l'execution effective des commandes
+  virtual int   Execute(string& keyw, vector<string>& args, string& toks);
+protected:
+  string psfilename;
+  PSFile * mpsfile;
+};
+
+/* --Methode-- */
+W2PSModuleExecutor::W2PSModuleExecutor()
+{
+
+psfilename = "w2ps.ps";
+mpsfile = NULL;
+
+PIACmd * mpiac;
+NamedObjMgr omg;
+mpiac = omg.GetImgApp()->CmdInterpreter();
+
+// On enregistre deux nouvelles commandes 
+string hgrp = "Graphics";
+// commande w2pssetfilename
+string kw = "pssetfilename";
+string usage = "w2pssetfilename: Sets current PostScript file name\n" ;
+usage += "Usage: w2pssetfilename FileName ";
+mpiac->RegisterCommand(kw, usage, this, hgrp);
+// commande w2psgetfilename
+kw = "psgetfilename";
+usage = "w2psgetfilename: Prints current PostScript file name \n" ;
+usage += "Usage: w2psgetfilename ";
+mpiac->RegisterCommand(kw, usage, this, hgrp);
+// commande w2psclosefile
+kw = "psclosefile";
+usage = "w2psclosefile: close current postscript file \n" ;
+usage += "Usage: w2psclosefile ";
+mpiac->RegisterCommand(kw, usage, this, hgrp);
+// commande w2ps
+kw = "w2ps";
+usage = "w2ps: Current Window To PostScript \n" ;
+usage += "Usage: w2ps ";
+mpiac->RegisterCommand(kw, usage, this, hgrp);
+// commande w2eps
+kw = "w2eps";
+usage = "w2eps: Current Window To EncapsulatedPostScript \n" ;
+usage += "Usage: w2eps EPSFileName";
+mpiac->RegisterCommand(kw, usage, this, hgrp);
+// commande imagcmap2eps
+kw = "imagcmap2ps";
+usage = "w2ps: Current Image+ColorMap To PostScript \n" ;
+usage += "Usage: imagcmap2ps ";
+mpiac->RegisterCommand(kw, usage, this, hgrp);
+// commande imagcmap2eps
+kw = "imagcmap2eps";
+usage = "imagcmap2eps: Current Image+ColorMap To EncapsulatedPostScript \n" ;
+usage += "Usage: imagcmap2eps EPSFileName";
+mpiac->RegisterCommand(kw, usage, this, hgrp);
+}
+
+/* --Methode-- */
+W2PSModuleExecutor::~W2PSModuleExecutor()
+{
+  if(mpsfile) delete mpsfile;
+}
+
+/* --Methode-- */
+int W2PSModuleExecutor::Execute(string& kw, vector<string>& tokens, string&)
+{
+
+NamedObjMgr omg;
+if (kw == "pssetfilename") {
+  if (tokens.size() < 1) {
+    cout << "Usage: pssetfilename PSFileName" << endl;
+    return(0);
+    }
+  if (mpsfile) delete mpsfile;
+  mpsfile = NULL;
+  psfilename = tokens[0];
+}
+else if (kw == "psgetfilename") {
+  cout << " W2PS: PSFileName= " << psfilename << endl;
+}
+else if (kw == "psclosefile") {
+  if (mpsfile) { 
+    cout << "psclosefile: Closing file " << psfilename << endl; 
+    delete mpsfile;
+    mpsfile = NULL;
+    psfilename = "w2ps.ps";
+  }
+}
+else if ( (kw == "w2ps") || (kw == "w2eps") ) {
+  PIStdImgApp*  sapp = omg.GetImgApp();
+  if (sapp == NULL) {
+    cout << " W2PSModuleExecutor::Execute() No PIStdImgApp !" << endl;
+    return(0);
+  }
+  if (sapp->CurrentWindow() == NULL) {
+    cout << " W2PSModuleExecutor::Execute() No current window !" << endl;
+    return(0);
+  }
+  if (kw == "w2ps") {
+    if (mpsfile == NULL) 
+      mpsfile = new PSFile(psfilename.c_str(), PI_Portrait, PI_A4, 2., 2.);
+    sapp->CurrentWindow()->PSPrint(mpsfile,0,0);
+    cout << " w2ps: Current window to PS file " << psfilename << endl;
+  }
+  else if (kw == "w2eps") {
+    if (tokens.size() < 1) {
+      cout << "Usage: w2eps EPSFileName" << endl;
+      return(0);
+    }
+    PSFile epsfile(tokens[0].c_str());
+    sapp->CurrentWindow()->PSPrint(&epsfile,0,0);
+    cout << " w2eps: Current window to EPS file " << tokens[0] << endl;
+  }
+}
+else if ( (kw == "imagcmap2ps") || (kw == "imagcmap2eps") ) {
+  PIStdImgApp*  sapp = omg.GetImgApp();
+  if (sapp == NULL) {
+    cout << " W2PSModuleExecutor::Execute() No PIStdImgApp !" << endl;
+    return(0);
+  }
+  PIImage* curpimg = NULL;
+  if (sapp->CurrentBaseWdg()) 
+    curpimg = dynamic_cast<PIImage *>(sapp->CurrentBaseWdg());
+  if (curpimg == NULL) {
+    cout << " W2PSModuleExecutor::Execute() No current PIImage !" << endl;
+    return(0);
+  }
+  PSFile * cpsf = NULL;
+  PSFile * cepsf = NULL;
+  if (kw == "imagcmap2ps") {
+    if (mpsfile == NULL) 
+      mpsfile = new PSFile(psfilename.c_str(), PI_Portrait, PI_A4, 2., 2.);
+    cpsf = mpsfile;
+    cout << " imagcmap2ps: Current image+colormap to PS file " << psfilename << endl;
+  }
+  else if (kw == "imagcmap2eps") {
+    if (tokens.size() < 1) {
+      cout << "Usage: imagcmap2eps EPSFileName" << endl;
+      return(0);
+    }
+    cepsf = new PSFile(tokens[0].c_str());
+    cpsf = cepsf;
+    cout << " imagcmap2eps: Current image+colormap to EPS file " << tokens[0] << endl;
+  }
+  bool fggd = (curpimg->XSize() > sapp->CMapVW()->XSize()) ? true : false;
+  int sx, sy, dxoi,dxoc;
+  if (fggd) {
+    sx = curpimg->XSize();
+    dxoi = 0;
+    dxoc = (sx-sapp->CMapVW()->XSize())/2;
+  }
+  else {
+    sx = sapp->CMapVW()->XSize();
+    dxoc = 0;
+    dxoi = (sx-curpimg->XSize())/2;
+  }
+  sy = curpimg->YSize() + sapp->CMapVW()->YSize() + 10;
+  cpsf->NewPage((float)sx, (float)sy, PI_Auto);
+  curpimg->PSPrint(cpsf, -curpimg->XPos()+dxoi, -curpimg->YPos());
+  sapp->CMapVW()->PSPrint(cpsf, -(sapp->CMapVW()->XPos())+dxoc, 			
+			  -(sapp->CMapVW()->YPos())+curpimg->YSize()+10);
+
+  if (cepsf) delete cepsf;
+}
+
+return(0);
+
+}
+
+static W2PSModuleExecutor * piaw2psex = NULL;
+/* Nouvelle-Fonction */
+void W2PSModule_init()
+{
+// Fonction d'initialisation du module
+// Appele par le gestionnaire de modules de piapp (PIACmd::LoadModule())
+if (piaw2psex) delete piaw2psex;
+piaw2psex = new W2PSModuleExecutor;
+}
+
+/* Nouvelle-Fonction */
+void W2PSModule_end()
+{
+// Desactivation du module
+if (piaw2psex) delete piaw2psex;
+piaw2psex = NULL;
+}
+
