Index: trunk/SophyaPI/PIext/pistdimgapp.cc
===================================================================
--- trunk/SophyaPI/PIext/pistdimgapp.cc	(revision 210)
+++ trunk/SophyaPI/PIext/pistdimgapp.cc	(revision 293)
@@ -1,2 +1,3 @@
+#include "machdefs.h"
 #include <stdlib.h>
 #include <stdio.h>
@@ -10,5 +11,4 @@
 #endif
 
-#include "machine.h"
 
 #include "strutil.h"
@@ -30,8 +30,4 @@
 
 
-//  Il faudra virer ca (?)  Reza 19/08/98 
-// #include "parmst.h"
-// #define  FLAG_MAINGLPARMPIA  1
-// #include "glparmpia.h"
 static char ImgDir[256];
 static char WorkDir[256];
@@ -49,4 +45,5 @@
 // Les menus
 m[0] = new PIMenu(Menubar(),"Fichier");
+m[0]->AppendItem("Help", 10100);
 m[0]->AppendItem("Open-Fits", 10120);
 m[0]->AppendItem("Open-PPF", 10130);
@@ -66,4 +63,6 @@
 m[2]->AppendItem("Extract Pave", 10305);
 m[2]->SetSensitivityMsg(10305, false);
+m[2]->AppendItem("Cuts X,Y", 10306);
+m[2]->SetSensitivityMsg(10306, false);
 mc = new PIMenu(m[2], "StackTools");
 mc->AppendItem("DispNext", 10320);
@@ -100,4 +99,6 @@
 m[5]->AppendCheckItem("Catch SigFPE/SEGV", 10603);
 
+m[6] = new PIMenu(Menubar(),"Modules");
+
 AppendMenu(m[0]);
 AppendMenu(m[1]);
@@ -106,4 +107,5 @@
 AppendMenu(m[4]);
 AppendMenu(m[5]);
+AppendMenu(m[6]);
 
 int scsx, scsy;
@@ -131,4 +133,5 @@
 mCons->SetBinding(PIBK_fixed,PIBK_fixed,PIBK_fixed, PIBK_fixed); 
 mCons->AcceptCmd(true, 50);
+redirecout = false;
 // RedirectStdOutErr(true);  pas par defaut 
 
@@ -151,6 +154,4 @@
 
 pfc = new PIFileChooser(this,"FileChooser", 5000); 
-
-// mCutTC = new CutTools(this, this->MainWin());
 
 mObjmgrw = new ObjMgrWind(this);
@@ -200,5 +201,5 @@
 
 delete mc;
-for(i=0; i<6; i++)  
+for(i=0; i<7; i++)  
   if (m[i]) delete m[i];
 
@@ -242,18 +243,19 @@
 if (smm == PIMsg_Active)
   {
-  sndw = (PIWdg *)sender;
+  sndw = dynamic_cast<PIWdg *>(sender);
   switch(sndw->kind())
     {
     case PIWindow::ClassId :
-      mCurWin = (PIWindow *)sender;
+      mCurWin = dynamic_cast<PIWindow *>(sndw);
       break;
 
     case PIScDrawWdg::ClassId :
     case PIDraw3DWdg::ClassId :
-      mCurWdg = (PIBaseWdg *)sender;
+      mCurWdg = dynamic_cast<PIBaseWdg *>(sender);
 //      cerr << "*DBG11* ImgTools -> NonSensitive " << sndw->kind() << endl;
       if (mFgCWImg) {
 //        cerr << "*DBG* ImgTools -> NonSensitive " << endl;
         m[2]->SetSensitivityMsg(10305, false);
+        m[2]->SetSensitivityMsg(10306, false);
         m[4]->SetSensitivityMsg(10515, false);
         m[4]->SetSensitivityMsg(10516, false);
@@ -262,8 +264,9 @@
       break;
     case PIImage::ClassId :
-      mCurWdg = (PIBaseWdg *)sender;
+      mCurWdg = dynamic_cast<PIBaseWdg *>(sender);
       if (!mFgCWImg) {
 //        cerr << "*DBG* ImgTools -> Sensitive " << endl;
         m[2]->SetSensitivityMsg(10305, true);
+        m[2]->SetSensitivityMsg(10306, true);
         m[4]->SetSensitivityMsg(10515, true);
         m[4]->SetSensitivityMsg(10516, true);
@@ -271,4 +274,16 @@
         }
       break;
+      /*
+    default :
+      mCurWdg = NULL;
+      if (mFgCWImg) {
+        m[2]->SetSensitivityMsg(10305, false);
+        m[2]->SetSensitivityMsg(10306, false);
+        m[4]->SetSensitivityMsg(10515, false);
+        m[4]->SetSensitivityMsg(10516, false);
+        mFgCWImg = false;
+        }
+      break;
+      */
     }
   }
@@ -301,5 +316,5 @@
   SetBusy();
   TRY {
-    CmdInterpreter()->Do(s);
+    mCmd->Interpret(s);
     }  CATCH(merr) { 
     fflush(stdout); 
@@ -448,5 +463,5 @@
 if (title.length() <= 0)  title = name;  string t2="";   
 scw->SetTitles(title, t2);    
-// scw->Refresh();  Pas necessaire  Reza 19/08/98 $CHECK$ 
+// scw->Refresh();   ? Pas necessaire  Reza 19/08/98, 05/05/99 $CHECK$ 
 mCurWin = win;
 mCurWdg = scw;
@@ -495,5 +510,5 @@
 if (title.length() <= 0)  title = name;  string t2="";   
 wd3->SetTitles(title, t2);    
-// wd3->Refresh();  Pas necessaire   
+// wd3->Refresh();   ?Pas necessaire   $CHECK$ 05/05/99
 mCurWin = win;
 mCurWdg = wd3;
@@ -522,5 +537,5 @@
 mWList[mWId*10+1] = (PIWindow*)win;
 win->SetAutoDelChilds(true);
-win->Show();
+// win->Show();
 mGrW = win; 
 mGrIdx = 0;
@@ -540,5 +555,5 @@
 mWList[mWId*10+2] = (PIWindow*)win;
 win->SetAutoDelChilds(true);
-win->Show();
+// win->Show();
 mStW = win;
 m[2]->SetSensitivity("StackTools", true); 
@@ -588,5 +603,5 @@
     mWList[mWId*10] = rw;
     rw->SetAutoDelChilds(true);
-    rw->Show();
+    //    rw->Show();
     px = py = 0;
     flag = 0;
@@ -595,5 +610,5 @@
   }
 
-// rw->Show();
+rw->Show();
 mCurWin = rw;
 return(rw);
@@ -713,4 +728,5 @@
   RedirectErrStream(mCons);
   m[5]->SetStateMsg(10602, true);
+  redirecout = true;
   }
 else {
@@ -718,4 +734,5 @@
   RedirectErrStream(NULL);
   m[5]->SetStateMsg(10602, false);
+  redirecout = false;
   }
 return;
@@ -745,4 +762,8 @@
   switch(msg)
     {
+    case 10100 :
+      mCmd->ShowHelpWindow();
+      break;
+
     case 10120 :
       pfc->SetPath(ImgDir);
@@ -894,4 +915,16 @@
     ObjMgr()->AddObj(pim, nom);
     ObjMgr()->DisplayObj(nom, "w");
+    break;
+    }
+
+  case 10306 :
+    {
+    PIImage* curpimg = NULL;
+    if (!mCurWdg)  return;
+    if (mCurWdg->kind() != PIImage::ClassId)  return;
+    curpimg = (PIImage*)mCurWdg;
+    if (curpimg == NULL)   return;
+    curpimg->ShowCuts(true);
+    break;
     }
 
