Index: trunk/SophyaPI/PIext/nobjmgr.cc
===================================================================
--- trunk/SophyaPI/PIext/nobjmgr.cc	(revision 361)
+++ trunk/SophyaPI/PIext/nobjmgr.cc	(revision 368)
@@ -91,4 +91,6 @@
 static string* TmpDir;  // Repertoire pour les compilations / link dynamique
 
+static bool BeQuiet = false;  // Moins de messages ...
+
 // Pour completer le nom de l'objet avec le nom du repertoire
 static void RemoveSpacesFromName(string & nom);
@@ -121,4 +123,7 @@
   SetKeepOldDirAtt(dirn, true);
   dirn = "tmp";
+  CreateDir(dirn);
+  SetKeepOldDirAtt(dirn, false);
+  dirn = "func";
   CreateDir(dirn);
   SetKeepOldDirAtt(dirn, false);
@@ -239,5 +244,5 @@
   (myImgApp->ObjMgrW())->DelDirectory((*it).second.id);
 myDirs->erase(it);
-cout << "amedObjMgr::DeleteDir() " << dirname << " deleted " << endl;  
+cout << "NamedObjMgr::DeleteDir() " << dirname << " deleted " << endl;  
 return(true);
 }
@@ -334,12 +339,33 @@
 
 /* --Methode-- */
-void NamedObjMgr::CleanTmpDir()
-{
-}
-
-/* --Methode-- */
-void NamedObjMgr::CleanOldDir()
-{
-}
+void NamedObjMgr::CleanDir(string & dirname)
+{
+if ( !CheckDirName(dirname) ) {
+  cout << "NamedObjMgr::CleanDir( " << dirname << ") Error - Invalid name !" << endl;
+  return(false); 
+  }
+NObjDirList::iterator itr = myDirs->find(dirname);
+if (itr == myDirs->end()) {
+  cout << "NamedObjMgr::CleanDir( " << dirname << ") Error - No such directory !" << endl;
+  return(false);
+  }
+
+int did = (*itr).second.id;
+NObjList::iterator it;  
+list<int>::iterator iwr;
+bool nodisp = true;
+list<string> odel;
+for(it = myObjs->begin(); it != myObjs->end(); it++) {
+  if ((*it).second.dirid != did) continue;
+  nodisp = true;
+  if (myImgApp) 
+    for(iwr=(*it).second.wrsid.begin(); iwr != (*it).second.wrsid.end(); iwr++) 
+      if (myImgApp->CheckWRsId(*iwr)) { nodisp = false; break; }
+  if (nodisp) odel.push_back((*it).first);
+  }
+list<string>::iterator ii;
+for(ii=odel.begin(); ii != odel.end(); ii++)  DelObj(*ii,true);
+}
+
 
 
@@ -390,4 +416,11 @@
   }
 
+// Si c'est le repertoire /func, on nettoie
+if (nrep == "func")  {
+  BeQuiet = true;   
+  CleanDir(nrep);
+  BeQuiet = false;
+  }
+
 myNObj++;
 if (nobj.length() < 1) { 
@@ -404,5 +437,10 @@
 it = myObjs->find(nom);
 if (it != myObjs->end()) { // l'objet existe deja
-  if ( (*itr).second.keepold ) { // On met l'ancien objet dans /old
+  if (nrep == "func") {  // Dans /func , on garde les objets affiches, donc del. par Clean
+    sprintf(buff, "%d", (*it).second.oid); 
+    string nomnew = "/func/" + nobj + buff;
+    RenameObj(nom, nomnew);
+    }                              
+  else if ( (*itr).second.keepold ) { // On met l'ancien objet dans /old
     string on,od;
 //    ParseObjectName((*it).first, od, on); 
@@ -501,4 +539,5 @@
 (*itr).second.nobj--;
 
+if (BeQuiet) return(true);  
 if (fgd) cout << "NamedObjMgr::DelObj()  Object " << nom << " deleted (Total= " << myObjs->size() << ")" << endl;
 else  cout << "NamedObjMgr::DelObj()  Object " << nom << " removed (Total= " << myObjs->size() << ")" << endl;
Index: trunk/SophyaPI/PIext/nobjmgr.h
===================================================================
--- trunk/SophyaPI/PIext/nobjmgr.h	(revision 361)
+++ trunk/SophyaPI/PIext/nobjmgr.h	(revision 368)
@@ -41,6 +41,5 @@
   virtual void		ListDirs(string & patt);
   virtual void		GetDirList(string & patt, vector<string>& );
-  virtual void		CleanTmpDir();
-  virtual void		CleanOldDir();
+  virtual void		CleanDir(string & dirname);
 
 //  Pour ajouter, supprimer et acceder aux objets 
Index: trunk/SophyaPI/PIext/piacmd.cc
===================================================================
--- trunk/SophyaPI/PIext/piacmd.cc	(revision 361)
+++ trunk/SophyaPI/PIext/piacmd.cc	(revision 368)
@@ -440,10 +440,15 @@
 
 /* Fonction */
-static string GetStringFrStdin()
-{
+static string GetStringFrStdin(PIACmd* piac)
+{
+PIStdImgApp* piapp = piac->GetImgApp();
+if (piapp) {
+  PIBaseWdg* wdg = piapp->CurrentBaseWdg();
+  if (wdg)  wdg->Refresh();
 #ifndef __mac__
-/* On vide le buffer X-Window */
-XFlush(PIXDisplay());
+  /* On vide le buffer X-Window */
+  XFlush(PIXDisplay());
 #endif
+}
 char buff[128];
 fgets(buff, 128, stdin);
@@ -702,5 +707,5 @@
   mImgApp->GetConsole()->AddStr(">>> Reading From StdIn \n", PIVA_Magenta);
   cout << tokens[0] << " ? " << endl;
-  mVars[tokens[0]] = GetStringFrStdin();
+  mVars[tokens[0]] = GetStringFrStdin(this);
   }
 
Index: trunk/SophyaPI/PIext/piafitting.cc
===================================================================
--- trunk/SophyaPI/PIext/piafitting.cc	(revision 361)
+++ trunk/SophyaPI/PIext/piafitting.cc	(revision 368)
@@ -29,4 +29,6 @@
 
 ////      ----------    Classe de fenetre de fit interactive ------------
+#define FINPARMAX  10    // Nb maxi de parametres de fit 
+
 class PIAFitterWind :  public PIWindow {
 public :
@@ -36,12 +38,16 @@
   virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
   inline  void  SetObjName(string& nom) { oname = nom; }
+          void  SetNbParms(int npar);
 protected :
   PIStdImgApp* dap;
   PIAFitter* fitter;
+  PILabel* labn;  
   PIOptMenu* pom[2];
-  PILabel* lab[2];  // Maximum 20 parametres
-  PIText* txt[2];   //     "    "      " 
   PIButton* but[2];
   PICheckBox* ckb[2];
+  PILabel* lab[2];
+  PILabel* labp[FINPARMAX];   // Maximum FINPARMAX  parametres
+  PIText* txtp[FINPARMAX];    //        "       "      "
+  PIText* txts[FINPARMAX];    //        "       "      "  
   string oname;
 };
@@ -101,5 +107,10 @@
 }
 else if (kw == "fitw") {
+  if (tokens.size() < 1) {
+    cout << "Usage: fitw nomobj" << endl;
+    return(0);
+    }
   cout << " *DBG* Affichage PIAFitterWind ** " << endl;
+  fwind->SetObjName(tokens[0]);
   fwind->Show();
  }
@@ -592,28 +603,25 @@
 spy = bsy/4;
 
-int wszx = 5*spx+3*bsx; 
+int wszx = 3*spx+4*bsx; 
 int wszy = 5*bsy+6*spy;
 SetSize(wszx, wszy);
 int cpx = spx;
 int cpy = spy;
-int csx = cpx;
-int csy = cpy;
-lab[0] = new PILabel(this, "Object", 1.5*bsx, bsy, cpx, cpy);
+
+cpx = spx+bsx;
+labn = new PILabel(this, "ObjectName", 2.0*bsx, bsy, cpx, cpy);
+labn->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
+
 cpy += spy+bsy;
-lab[1] = new PILabel(this, "Params", 1.5*bsx, bsy, cpx, cpy);
-cpx += bsx*1.5+spx;
-
-cpy = spy;
-txt[0] = new PIText(this, "", 3.5*bsx, bsy, cpx, cpy);
+cpx = spx;
+ckb[0] = new PICheckBox(this,"Gen.Func", 1001, 2*bsx, bsy, cpx, cpy);
+cpx += bsx*2+spx;
+ckb[1] = new PICheckBox(this,"Gen.Resid", 1002, 2*bsx, bsy, cpx, cpy);
+ckb[0]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
+ckb[1]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
+
 cpy += spy+bsy;
-txt[1] = new PIText(this, "1.", 3.5*bsx, bsy, cpx, cpy);
-
-cpy += spy+bsy;
-ckb[0] = new PICheckBox(this,"Gen.Func", 1001, 2.5*bsx, bsy, cpx, cpy);
-cpx += bsx*1.5+spx;
-ckb[1] = new PICheckBox(this,"Gen.Resid", 1002, 2.5*bsx, bsy, cpx, cpy);
-
-cpy += spy+bsy;
-pom[0] = new PIOptMenu(this, "FitFunc", 2.5*bsx, bsy, cpx, cpy);
+cpx = spx;
+pom[0] = new PIOptMenu(this, "FitFunc", 2*bsx, bsy, cpx, cpy);
 pom[0]->AppendItem("Poly0", 100);
 pom[0]->AppendItem("Poly1", 101);
@@ -623,34 +631,107 @@
 pom[0]->AppendItem("Gauss+Poly1",105);
 pom[0]->AppendItem("Gauss+Poly2",106);
-
-cpx += bsx*1.5+spx;
-pom[1] = new PIOptMenu(this, "Bidon", 2.5*bsx, bsy, cpx, cpy);
-pom[1]->AppendItem("Un", 150);
-pom[1]->AppendItem("Deux",250);
-pom[1]->AppendItem("Trois",350);
+pom[0]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
+
+cpx += bsx*2+spx;
+pom[1] = new PIOptMenu(this, "NPar", 2*bsx, bsy, cpx, cpy);
+pom[1]->AppendItem("Un NP=1", 201);
+pom[1]->AppendItem("Deux NP=2",202);
+pom[1]->AppendItem("Trois NP=3",203);
+pom[1]->AppendItem("Cinq  NP=5",205);
+pom[1]->AppendItem("Huit  NP=8",208);
+pom[1]->AppendItem("Dix  NP=10",210);
+pom[1]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
 
 cpy += spy+bsy;
-cpx = 0.5*spx;
-but[0] =  new PIButton(this, "DoFit", 555, bsx*2, bsy, cpx, cpy);
-cpx += 3*spx;
-but[1] =  new PIButton(this, "Dismiss", 777, bsx*2, bsy, cpx, cpy);
-
-}
+cpx = 0.5*bsx;
+but[0] =  new PIButton(this, "DoFit", 555, bsx*1.5, bsy, cpx, cpy);
+cpx += bsx*1.5+3*spx;
+but[1] =  new PIButton(this, "Dismiss", 777, bsx*1.5, bsy, cpx, cpy);
+but[0]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
+but[1]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
+
+//  Pour les parametres
+cpy += bsy+spy;
+cpx = 0.6*bsx+1.5*spx;
+lab[0] = new PILabel(this, "Init.Val", 1.7*bsx, bsy, cpx, cpy);
+cpx += 1.7*bsx+0.5*spx;
+lab[1] = new PILabel(this, "Step", 1.7*bsx, bsy, cpx, cpy);
+lab[0]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
+lab[1]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
+
+for(int i=0; i<FINPARMAX; i++) {
+  char buff[32];
+  cpy += bsy+spy;
+  cpx = spx;
+  sprintf(buff, "P%d",i);
+  labp[i] = new PILabel(this, buff, 0.6*bsx, bsy, cpx, cpy);
+  labp[i]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
+  sprintf(buff, "Val%d",i);
+  cpx += 0.6*bsx+0.5*spx;
+  txtp[i] = new PIText(this, buff, 1.7*bsx, bsy, cpx, cpy);
+  txtp[i]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
+  sprintf(buff, "Step%d",i);
+  cpx += 1.7*bsx+0.5*spx;
+  txts[i] = new PIText(this, buff, 1.7*bsx, bsy, cpx, cpy);
+  txts[i]->SetBinding(PIBK_elastic, PIBK_fixed, PIBK_elastic, PIBK_free);
+  }  
+}
+
 /* --Methode-- */
 PIAFitterWind::~PIAFitterWind()
 {
-for(int i=0; i<2; i++) {
-  delete lab[i];
-  delete txt[i];
+int i;
+for(i=0; i<2; i++) {
   delete pom[i];
   delete ckb[i];
   delete but[i];
   }
-}
+delete labn;
+delete lab[0];
+delete lab[1];
+for(i=0; i< FINPARMAX; i++) {
+  delete labp[i];
+  delete txtp[i];
+  delete txts[i];
+  }
+}
+
+/* --Methode-- */
+void PIAFitterWind::SetNbParms(int npar)
+{
+if (npar < 1) npar = 1;
+if (npar > FINPARMAX) npar = FINPARMAX;
+
+int bsx, bsy, spx, spy;
+
+dap->PrefCompSz(bsx, bsy);
+spx = bsx/10;
+spy = bsy/4;
+
+int wszx = 3*spx+4*bsx; 
+int wszy = (5+npar)*bsy+(6+npar)*spy;
+SetSize(wszx, wszy);
+
+int i;
+for(i=0; i<npar; i++) {
+  labp[i]->Manage();
+  txtp[i]->Manage();
+  txts[i]->Manage();
+  }
+for(i=npar; i<FINPARMAX; i++) {
+  labp[i]->UnManage();
+  txtp[i]->UnManage();
+  txts[i]->UnManage();
+  }
+
+}
+
 /* --Methode-- */
 void PIAFitterWind::Show()
 {
 // Si on veut initialiser des trucs au moment ou apparait la fenetre
-txt[0]->SetText(oname);
+labn->SetLabel(oname);
+SetNbParms(3);
+pom[1]->SetValue(203);
 PIWindow::Show();
 }
@@ -662,4 +743,10 @@
 char *mf[7] = {"p0","p1","p2","g","g0","g1","g2"};
 msg = UserMsg(msg);
+
+if ((msg > 200) && (msg <= 200+FINPARMAX)) {  // On change le nombre de parametre
+  SetNbParms(msg-200);
+  return;
+  }
+  
 if (msg == 777)  { Hide(); return; }  // On cache la fenetre
 
@@ -674,5 +761,4 @@
   cmd += " " + a + " ";
   args.push_back(a);
-  a = txt[1]->GetText();  // Definition des parametres
   cmd += a;
   args.push_back(a);
Index: trunk/SophyaPI/PIext/pistdimgapp.cc
===================================================================
--- trunk/SophyaPI/PIext/pistdimgapp.cc	(revision 361)
+++ trunk/SophyaPI/PIext/pistdimgapp.cc	(revision 368)
@@ -767,4 +767,20 @@
   }
 }
+/* --Methode-- */
+bool PIStdImgApp::CheckWRsId(int k)
+{
+if (k > 0) { // C'est un BaseWidget
+  BWMList::iterator it;
+  it  = mBWList.find(k);
+  if (it == mBWList.end())  return(false);
+  else return(true);
+  }
+else {  // C'est un drawer
+  DrwMList::iterator it;
+  it  = mDrwList.find(-k);
+  if (it == mDrwList.end())  return(false);
+  else return(true);
+  }
+}
 
 
Index: trunk/SophyaPI/PIext/pistdimgapp.h
===================================================================
--- trunk/SophyaPI/PIext/pistdimgapp.h	(revision 361)
+++ trunk/SophyaPI/PIext/pistdimgapp.h	(revision 368)
@@ -69,4 +69,5 @@
      void DeleteBaseWidget(PIBaseWdg* w, bool dw=true, bool dwin=true);
      void DelWRsId(int k);
+     bool CheckWRsId(int k);
      void CloseAllWindows();
 
Index: trunk/SophyaPI/PIext/servnobjm.cc
===================================================================
--- trunk/SophyaPI/PIext/servnobjm.cc	(revision 361)
+++ trunk/SophyaPI/PIext/servnobjm.cc	(revision 368)
@@ -203,5 +203,5 @@
   if (nom.length() < 1) {
      titre = "Function f(x)";
-     nom = "/home/func";
+     nom = "/func/f_x";
     }
   else titre = nom;
@@ -265,5 +265,5 @@
   if (nom.length() < 1) {
      titre = "Function f(x,y)";
-     nom = "/home/func2d";
+     nom = "/func/f2d_xy";
     }
   else titre = nom;
