Changeset 18 in Sophya
- Timestamp:
- Jul 6, 1996, 11:28:11 AM (29 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 34 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/Makefile
r17 r18 82 82 83 83 all: $(LIB)libPI.a 84 $(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)pimenubargen.o $(OBJ)pimenubarx.o $(OBJ)pimenugen.o $(OBJ)pimenux.o $(OBJ)pimsghandler.o $(OBJ)pioptmenugen.o $(OBJ)pioptmenux.o $(OBJ)pip ixmapgen.o $(OBJ)pipixmapx.o $(OBJ)piscdrawwdg.o $(OBJ)pistdwdggen.o $(OBJ)pistdwdgx.o $(OBJ)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o84 $(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)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)piwdggen.o $(OBJ)piwdgx.o $(OBJ)piwindowgen.o $(OBJ)piwindowx.o $(OBJ)pixtbase.o 85 85 $(AR) $(ARFLAGS) $@ $? 86 86 … … 180 180 pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h picmapx.h \ 181 181 picmapgen.h 182 $(OBJ)piperiodx.o: ./piperiodx.cc ./piperiodx.h $(INC)periodic.h 182 183 $(OBJ)pipixmapx.o: ./pipixmapx.cc pipixmapx.h pipixmapgen.h pisysdep.h \ 183 184 pibwdgx.h pibwdggen.h piwdgx.h piwdggen.h pimsghandler.h picmap.h \ -
trunk/SophyaPI/PI/piapplgen.cc
r2 r18 2 2 3 3 PIApplicationGen::PIApplicationGen() 4 :topcont(NULL), menubar(NULL) 4 :topcont(NULL), menubar(NULL), mState(0) 5 5 {} 6 6 … … 15 15 return; 16 16 } 17 18 void PIApplicationGen::SetReady() 19 { 20 mState = kReadyState; 21 } 22 23 void PIApplicationGen::SetBusy() 24 { 25 mState = kBusyState; 26 } 27 28 void PIApplicationGen::SetBlocked() 29 { 30 mState = kBlockedState; 31 } 32 33 int PIApplicationGen::GetState() 34 { 35 return mState; 36 } 37 -
trunk/SophyaPI/PI/piapplgen.h
r2 r18 9 9 class PIApplicationGen : public PIMsgHandler { 10 10 public: 11 enum { kReadyState=0, kBusyState=1, kBlockedState=2 }; 12 11 13 PIApplicationGen(); 12 14 virtual ~PIApplicationGen(); … … 14 16 virtual void Run()=0; 15 17 virtual void Stop()=0; 18 19 virtual void SetReady(); 20 virtual void SetBusy(); 21 virtual void SetBlocked(); 22 virtual int GetState(); 23 16 24 17 25 virtual PIContainer* MainWin() {return topcont;} … … 22 30 PIContainer *topcont; 23 31 PIMenubar *menubar; 32 int mState; 24 33 }; 25 34 -
trunk/SophyaPI/PI/piapplx.cc
r7 r18 1 1 #include <stdio.h> 2 #include <X11/cursorfont.h> 2 3 #include "piapplx.h" 3 4 #include "picontainerx.h" … … 5 6 6 7 #define DEBUG_APPLX 8 9 static Cursor a_curs[3]; 10 static bool a_fgcur=false; 7 11 8 12 /* --Methode-- */ … … 38 42 MBCont()->Show(); 39 43 topwdg->Manage(); 44 45 if (!a_fgcur) 46 { 47 Display *mdsp; 48 mdsp = XtDisplay (topwdg->XtWdg()); 49 a_curs[0] = XCreateFontCursor(mdsp, XC_arrow); 50 a_curs[1] = XCreateFontCursor(mdsp, XC_X_cursor); 51 a_curs[2] = XCreateFontCursor(mdsp, XC_watch); 52 } 53 54 mState = -1; 55 SetReady(); 40 56 } 41 57 … … 46 62 puts("PIApplicationX::~PIApplicationX()_info : App delete"); 47 63 #endif 64 Display *mdsp; 65 mdsp = XtDisplay (topwdg->XtWdg()); 48 66 topwdg->Unmanage(); 49 67 delete menubar; … … 51 69 delete intcont; 52 70 delete topwdg; 53 exit(0); 71 XtCloseDisplay(mdsp); 72 return; 54 73 } 55 74 … … 71 90 return; 72 91 } 92 93 94 /* --Methode-- */ 95 void PIApplicationX::SetReady() 96 { 97 if (mState != kReadyState) 98 { 99 Display * mdsp; 100 mState = kReadyState; 101 mdsp = XtDisplay (topwdg->XtWdg()); 102 XDefineCursor(mdsp, XtWindow(topwdg->XtWdg()), a_curs[0]); 103 XFlush(mdsp); 104 } 105 } 106 107 /* --Methode-- */ 108 void PIApplicationX::SetBusy() 109 { 110 if (mState != kBusyState) 111 { 112 Display * mdsp; 113 mState = kBusyState; 114 mdsp = XtDisplay (topwdg->XtWdg()); 115 // if ( XtIsRealized(topwdg->XtWdg()) ) 116 XDefineCursor(mdsp, XtWindow(topwdg->XtWdg()), a_curs[2]); 117 XFlush(mdsp); 118 } 119 return; 120 } 121 122 /* --Methode-- */ 123 void PIApplicationX::SetBlocked() 124 { 125 if (mState != kBlockedState) 126 { 127 Display * mdsp; 128 mState = kBlockedState; 129 mdsp = XtDisplay (topwdg->XtWdg()); 130 XDefineCursor(mdsp, XtWindow(topwdg->XtWdg()), a_curs[1]); 131 XFlush(mdsp); 132 } 133 } -
trunk/SophyaPI/PI/piapplx.h
r2 r18 16 16 virtual void Stop() { mStop = false; } 17 17 18 virtual void SetReady(); 19 virtual void SetBusy(); 20 virtual void SetBlocked(); 21 18 22 PIContainer* MBCont() { return intcont; } 19 23 protected: -
trunk/SophyaPI/PI/pibwdggen.cc
r11 r18 43 43 void PIBaseWdgGen::But1Press(int /*x*/, int /*y*/) 44 44 { 45 Send(PIMsg_ActiveWdg); 45 46 #ifdef DEBUG_RZXB 46 47 printf ("PIBaseWdgGen::But1Press PosX,Y= %d %d \n", x, y); -
trunk/SophyaPI/PI/pibwdgx.cc
r11 r18 584 584 void PIBaseWdgX::But1Release(int x, int y) 585 585 { 586 Send(PIMsg_ActiveWdg); 586 587 #ifdef DEBUG_PIBWDGX 587 588 printf ("PIBaseWdgX::ButReleasePosX,Y= %d %d \n", x, y); … … 643 644 #ifdef DEBUG_PIBWDGX 644 645 printf("PIBaseWdgX::Keyboard: Key= %d (%c) Mod= %d \n", key, (char)key, (int)kmod); 645 X Sync(XtDisplay(this->XtWdg()), 0);646 XFlush(XtDisplay(this->XtWdg())); 646 647 #endif 647 648 return; -
trunk/SophyaPI/PI/picontainergen.cc
r2 r18 1 1 #include "picontainergen.h" 2 3 4 #define NCHALGRP 4 2 5 3 6 /* --Methode-- */ … … 5 8 int sx, int sy, int px, int py) 6 9 : PIWdg(par, nom, sx, sy, px, py) , stvis(0) 7 {} 10 { 11 mNCh = 0; 12 mACSup = mPaSup = false; 13 mChilds = new (PIWdgGen * [NCHALGRP]); 14 mMxCh = NCHALGRP; 15 } 8 16 9 17 10 18 /* --Methode-- */ 11 19 PIContainerGen::~PIContainerGen() 12 {} 20 { 21 mPaSup = true; // Pour prevenir ChildDel() 22 if (mACSup) 23 for(int i=0; i<mNCh; i++) delete mChilds[i]; 24 delete[] mChilds; 25 } 13 26 14 27 /* --Methode-- */ … … 16 29 { 17 30 stvis = 1; 18 return;19 }20 21 /* --Methode-- */22 void PIContainerGen::NewChild(PIWdgGen* /*child*/)23 {24 31 return; 25 32 } … … 38 45 } 39 46 47 /* --Methode-- */ 48 void PIContainerGen::ChildAdd(PIWdgGen* child) 49 { 50 if (child == NULL) return; 51 if (mNCh == mMxCh) 52 { 53 PIWdgGen ** och = mChilds; 54 mChilds = new (PIWdgGen * [mMxCh+NCHALGRP]); 55 for(int i=0; i<mNCh; i++) mChilds[i] = och[i]; 56 delete[] och; 57 mMxCh += NCHALGRP; 58 } 59 mChilds[mNCh] = child; mNCh++; 60 return; 61 } 62 63 /* --Methode-- */ 64 void PIContainerGen::ChildDel(PIWdgGen* child) 65 { 66 if (mPaSup) return; // Ne rien faire si delete initie par Container-parent 67 if ((child == NULL) || (mNCh < 1)) return; 68 for(int i=0; i<mNCh; i++) 69 if (mChilds[i] == child) 70 { 71 mNCh--; 72 mChilds[i] = mChilds[mNCh]; 73 break; 74 } 75 return; 76 } 77 78 79 /* --Methode-- */ 80 void PIContainerGen::SetAutoDelChilds(bool ad) 81 { 82 mACSup = ad; 83 return; 84 } -
trunk/SophyaPI/PI/picontainergen.h
r2 r18 16 16 virtual ~PIContainerGen(); 17 17 18 virtual void NewChild(PIWdgGen * child);18 virtual long kind() {return ClassId; } 19 19 20 20 virtual void Show(); … … 22 22 virtual int Visible(); 23 23 24 virtual long kind() {return ClassId; } 24 virtual void ChildAdd(PIWdgGen * child); 25 virtual void ChildDel(PIWdgGen * child); 25 26 27 void SetAutoDelChilds(bool ad = false); 26 28 protected: 27 29 int stvis; 30 PIWdgGen ** mChilds; 31 int mNCh, mMxCh; 32 bool mPaSup,mACSup; 28 33 }; 29 34 -
trunk/SophyaPI/PI/pidemo.cc
r16 r18 5 5 6 6 #include "perrors.h" 7 #include "ctimer.h" 7 8 #include "fitsimage.h" 9 #include "dynccd.h" 8 10 9 11 #include "strecinit.h" 12 13 #include "psf.h" 14 #include "nbmath.h" 10 15 11 16 #include "pidemo.h" … … 14 19 15 20 /* Pour le link dynamique */ 16 typedef FitsImageR4 * (* UsPrFunc) (FitsImageR4 * myimg, int xp, int yp, int dx, int dy,17 21 typedef ImageR4 * (* UsPrFunc) (ImageR4 * myimg, int xp, int yp, int dx, int dy, 22 char * arg1, char * arg2); 18 23 static UsPrFunc userFunc[3] = { NULL, NULL, NULL }; 19 24 static void *dlhandle = NULL; 20 25 21 static char userlibname[256]; 22 23 static int DynLink(char *usln); 24 25 int DynLink(char *usln) 26 /* Variables globales pour les options et parametres de pidemo */ 27 static int pav_sz=15; 28 static bool rect_pav=true; 29 static int typ_psf=1; 30 static bool prt_pval=true; 31 static DynCCD *mdynccd; // Initialise ds main() 32 static bool his_ckd=true; 33 static float his_min=0.; 34 static float his_max=2000.; 35 static int his_nbin=200; 36 static bool vis_cursshow=true; 37 static int vis_zoom=1; 38 /* Fin des options / variables globales */ 39 40 static int DynLink(bool fgmk); 41 42 /* Nouvelle-Fonction */ 43 int DynLink(bool fgmk) 26 44 { 27 45 UsPrFunc uf; 28 46 int i, rc; 29 47 30 if (usln != NULL) strncpy(userlibname, usln, 255); userlibname[255] = '\0'; 31 32 printf("PIDemo_DynLink(): Relinking from %s \n", userlibname); 48 #ifdef C_NO_SHLIBS 49 puts("PIDemo/DynLink() Warning: Cette version a ete cree sans ShLibs "); 50 puts(" ... Pas de possibite de link dynamique -> Pas de UserProc ... "); 51 for(i=0; i<3; i++) userFunc[i] = NULL; 52 return(0); 53 #endif 54 55 TIMEF 33 56 if (dlhandle != NULL) dlclose(dlhandle); 34 57 for(i=0; i<3; i++) userFunc[i] = NULL; 35 dlhandle = dlopen(userlibname, RTLD_NOW); 58 59 if (fgmk) 60 { 61 printf("PIDemo_DynLink(): Making user.so, Relinking from user.so -> piup.so \n"); 62 puts("PIDemo_DynLink(): Executing make -f piusmak piup.so "); 63 system("time make -f piusmak piup.so"); 64 SPLITTIME 65 } 66 67 dlhandle = dlopen("piup.so", RTLD_NOW); 36 68 if (dlhandle == NULL) 37 { printf("PIDemo_DynLink(), Erreur d'ouverture UserShLib %s \n", userlibname);69 { printf("PIDemo_DynLink(), Erreur d'ouverture UserShLib piup.so \n"); 38 70 return(100); } 39 71 rc = 0; 40 72 printf("PIDemo_DynLink(): Searching for PIUserProc_1 (Rc=%d) \n", rc); 41 uf = dlsym(dlhandle, "PIUserProc_1__FPt9FitsImage1ZfiiiiPcT5");73 uf = (UsPrFunc) dlsym(dlhandle, "PIUserProc_1__FPt5Image1ZfiiiiPcT5"); 42 74 if (uf != NULL) userFunc[0] = uf; 43 75 else rc += 2; 44 76 printf("PIDemo_DynLink(): Searching for PIUserProc_3 (Rc=%d) \n", rc); 45 uf = dlsym(dlhandle, "PIUserProc_2__FPt9FitsImage1ZfiiiiPcT5");77 uf = (UsPrFunc) dlsym(dlhandle, "PIUserProc_2__FPt5Image1ZfiiiiPcT5"); 46 78 if (uf != NULL) userFunc[1] = uf; 47 79 else rc += 4; 48 80 printf("PIDemo_DynLink(): Searching for PIUserProc_3 (Rc=%d) \n", rc); 49 uf = dlsym(dlhandle, "PIUserProc_3__FPt9FitsImage1ZfiiiiPcT5");81 uf = (UsPrFunc) dlsym(dlhandle, "PIUserProc_3__FPt5Image1ZfiiiiPcT5"); 50 82 if (uf != NULL) userFunc[2] = uf; 51 83 else rc += 8; … … 61 93 /* --Methode-- */ 62 94 PIDemoApp::PIDemoApp(char *path) 63 : PIApplication( 300, 200)64 { 65 for(int i=0; i<NMX IMG; i++)66 { wpii[i] = NULL; pii[i] = NULL; img[i] = NULL; }67 mN img = 0; mCur = NULL;68 mState = 0; 69 70 m[0] = new PIPDMenu((PIMsgHandler *)Menubar(),"File");95 : PIApplication(400, 230) 96 { 97 for(int i=0; i<NMXWIN; i++) 98 { awp[i] = NULL; taw[i] = 0; } 99 mNwin = 0; mTnw = 0; mCurWin = NULL; mCurPII = NULL; 100 101 m[0] = new PIPDMenu((PIMsgHandler *)Menubar(),"Fichier"); 102 m[0]->AppendItem("Options", 10110); 71 103 m[0]->AppendItem("Open", 10101); 72 104 m[0]->AppendItem("Close", 10102); … … 75 107 m[0]->AppendItem("Exit", 10105); 76 108 77 m[1] = new PIPDMenu((PIMsgHandler *)Menubar()," Image");78 m[1]->AppendItem("Lut...", 102 01);79 m[1]->AppendItem("Size*1", 102 02);80 m[1]->AppendItem("Expand*2", 102 03);81 m[1]->AppendItem("Compress*2", 1020 4);82 m[1]->AppendItem("Expand*4", 102 05);109 m[1] = new PIPDMenu((PIMsgHandler *)Menubar(),"Visual."); 110 m[1]->AppendItem("Lut...", 10221); 111 m[1]->AppendItem("Size*1", 10211); 112 m[1]->AppendItem("Expand*2", 10212); 113 m[1]->AppendItem("Compress*2", 10208); 114 m[1]->AppendItem("Expand*4", 10214); 83 115 m[1]->AppendItem("Compress*4", 10206); 84 85 m[2] = new PIPDMenu((PIMsgHandler *)Menubar(),"Operation"); 116 m[1]->AppendItem("CursorOFF", 10231); 117 m[1]->AppendItem("CursorON", 10232); 118 m[1]->AppendItem("PrintLut", 10222); 119 120 m[2] = new PIPDMenu((PIMsgHandler *)Menubar(),"Ope.Image"); 86 121 m[2]->AppendItem("UserProc-1", 10301); 87 122 m[2]->AppendItem("UserProc-2", 10302); 88 123 m[2]->AppendItem("UserProc-3", 10303); 89 m[2]->AppendItem("PixelHisto", 10304); 90 m[2]->AppendItem("PrintLut", 10305); 91 m[2]->AppendItem("CheckDyn", 10306); 124 m[2]->AppendItem("PixelHisto", 10331); 125 m[2]->AppendItem("Info (dyn)", 10332); 126 127 m[3] = new PIPDMenu((PIMsgHandler *)Menubar(),"Ope.Pave"); 128 m[3]->AppendItem("Extract", 10401); 129 m[3]->AppendItem("Coupe", 10410); 130 m[3]->AppendItem("Fit-PSF", 10420); 131 m[3]->AppendItem("PixelHisto", 10431); 132 m[3]->AppendItem("Print", 10432); 133 134 m[4] = NULL; 92 135 93 136 AppendMenu(m[0]); 94 137 AppendMenu(m[1]); 95 138 AppendMenu(m[2]); 96 97 zoom = new PIPixmap(this->MainWin(), "Zoom", 120,120,10,10); 98 labimg = new PILabel(this->MainWin(), "PixelValue", 280, 25, 10, 150); 139 AppendMenu(m[3]); 140 141 142 zoom = new PIPixmap(this->MainWin(), "Zoom", 140,140,10,20); 143 144 mTlb[0] = new PILabel(this->MainWin(), "Img: ", 40, 25, 5, 200); 145 labimg = new PILabel(this->MainWin(), "PixelValue", 345, 25, 50, 200); 99 146 labimg->SetLabel(""); 100 101 draw = new PIDrawWindow(this, "histo", PIWK_normal, 300, 300, 300, 300);102 pixelHisto = new Histo(0,2000, 200);103 draw->AddDrawer(piHisto=new PIHisto(pixelHisto)); 104 147 mTlb[1] = new PILabel(this->MainWin(), "Drw: ", 40, 25, 5, 170); 148 labdrw = new PILabel(this->MainWin(), "Coord", 140, 25, 50, 170); 149 labdrw->SetLabel(""); 150 151 lab = NULL; 105 152 // lab = new PILabel(this->MainWin(), "State", 60, 20, 150, 10); 106 153 // lab->SetBorderWidth(1); 107 154 108 olb[0] = new PILabel(this->MainWin(), "AutoLut :", 60, 25, 140, 30);109 pum[0] = new PIPUMenu((PIMsgHandler *)this, "AutoLut");110 pum[0]->AppendItem("+3 Sig", 20303);111 pum[0]->AppendItem("+2 Sig", 20302);112 pum[0]->AppendItem("+1 Sig", 20301);113 pum[0]->AppendItem("-1 Sig", 20299);114 pum[0]->AppendItem("-2 Sig", 20298);115 opm[0] = new PIOptMenu(this->MainWin(), pum[0], 80, 25, 210, 30);116 opm[0]->SetValue(20302);117 118 olb[1] = new PILabel(this->MainWin(), "Zoom :", 60, 25, 140, 70);119 pum[1] = new PIPUMenu((PIMsgHandler *)this, "Zoom");120 pum[1]->AppendItem("Agr. * 5", 20105);121 pum[1]->AppendItem("Agr. * 4", 20104);122 pum[1]->AppendItem("Agr. * 3", 20103);123 pum[1]->AppendItem("Agr. * 2", 20102);124 pum[1]->AppendItem("* 1", 20101);125 pum[1]->AppendItem("Red. / 2", 20098);126 pum[1]->AppendItem("Red. / 3", 20097);127 pum[1]->AppendItem("Red. / 4", 20096);128 pum[1]->AppendItem("Red. / 5", 20095);129 opm[1] = new PIOptMenu(this->MainWin(), pum[1], 80, 25, 210, 70);130 opm[1]->SetValue(20101);131 132 olb[2] = new PILabel(this->MainWin(), "ColMap :", 60, 25, 140, 110);133 pum[2] = new PIPUMenu((PIMsgHandler *)this, "ColMap");134 pum[2]->AppendItem("Grey32", 20201);135 pum[2]->AppendItem("GreyInv32", 20202);136 pum[2]->AppendItem("ColRJ32", 20203);137 pum[2]->AppendItem("ColBR32", 20204);138 pum[2]->AppendItem("ColRV32", 20205);139 opm[2] = new PIOptMenu(this->MainWin(), pum[2], 80, 25, 210, 110);140 opm[2]->SetValue(20203);141 155 142 156 pfc = new PIFileChooser(this,"FileChooser", 5000); … … 144 158 pfc->SetPath(path); 145 159 160 mVisTC = new VisuTools(this, this->MainWin()); 161 mCutTC = new CutTools(this, this->MainWin()); 162 163 mVisTC->Show(); 164 mTCId = 1; 146 165 147 166 mLutw = new LutWind(this); 148 167 mUP = new UserProcWind(this); 168 mOptw = new OptionWind(this); 149 169 150 170 SetReady(); … … 155 175 { 156 176 int i; 157 for(i=0; i<3; i++) 158 { 159 delete m[i]; 160 delete opm[i]; 161 delete pum[i]; 162 delete olb[i]; 163 } 164 delete pfc; 177 for(i=0; i<5; i++) delete m[i]; 178 165 179 delete lab; 166 180 167 for(i=0; i<mNimg; i++) 168 { 169 delete pii[i]; 170 delete img[i]; 171 delete wpii[i]; 172 } 181 for(i=0; i<mNwin; i++) 182 delete awp[i]; 173 183 174 184 delete zoom; 175 185 delete labimg; 176 177 delete draw; 178 delete pixelHisto; 179 delete piHisto; 186 delete labdrw; 187 delete mTlb[0]; 188 delete mTlb[1]; 189 190 delete pfc; 191 delete mVisTC; 192 delete mCutTC; 180 193 181 194 delete mLutw; 182 195 delete mUP; 196 delete mOptw; 183 197 184 198 } … … 187 201 void PIDemoApp::Process(long msg, PIMsgHandler* sender, void* data) 188 202 { 189 CMapId cmap[5] = { CMAP_GREY32, CMAP_GREYINV32, CMAP_COLRJ32, 190 CMAP_COLBR32, CMAP_COLRV32 } ; 191 192 193 if ((mState != 0) && (msg > 9999)) { PIBeep(); return; } 194 195 196 if ( (msg > 20000) && (CurrentPIImage()) ) 197 { 198 msg -= 20000; 199 if ((msg < 110) && (msg > 90)) // Zoom 200 CurrentPIImage()->SetZoom(msg-100); 201 else if ((msg > 200) && (msg < 206)) // Changement de couleur 202 CurrentPIImage()->SetColMap(cmap[msg-201]); 203 else if ((msg > 290) && (msg < 310)) 204 CurrentPIImage()->SetLut( CurrentImage()->minPix, CurrentImage()->maxPix, 205 kLutType_Lin, msg-300); 206 } 207 208 else 209 { 210 switch (msg) 203 PIWdg *sndw; 204 205 if ((GetState()) && (msg > 9999)) { PIBeep(); return; } 206 207 if ( (msg >= 5100) && (msg < 5200) ) MBProcess1(msg, sender, data); 208 else if ( (msg >= 10100) && (msg < 10200) ) MBProcess1(msg, sender, data); 209 else if ( (msg >= 10200) && (msg < 10300) ) MBProcess2(msg, sender, data); 210 else if ( (msg >= 10300) && (msg < 10400) ) MBProcess3(msg, sender, data); 211 else if ( (msg >= 10400) && (msg < 10500) ) MBProcess4(msg, sender, data); 212 else if (msg == PIMsg_ActiveWdg) 213 { 214 sndw = (PIWdg *)sender; 215 switch(sndw->kind()) 211 216 { 212 case PIMsg_ActiveWindow : 213 mCur = (PIImage *)sender; 217 case PIWindow::ClassId : 218 mCurWin = (PIWindow *)sender; 219 break; 220 case PIImage::ClassId : 221 mCurPII = (PIImage *)sender; 222 break; 223 } 224 } 225 else printf("PIDemoApp::Process() BUG?? Msg %d \n", (int)msg); 226 227 /* Changement palette outil */ 228 229 if (msg != 10410) 230 { 231 if (mTCId != 1) { mCutTC->Hide(); mVisTC->Show(); mTCId = 1; } 232 } 233 234 return; 235 } 236 237 /* --Methode-- */ 238 void PIDemoApp::MBProcess1(long msg, PIMsgHandler* /*sender*/, void* data) 239 { 240 241 switch(msg) 242 { 243 case 10110: 244 SetBlocked(); 245 mOptw->Show(); 214 246 break; 215 247 … … 234 266 case 10104: 235 267 SetBusy(); 236 DynLink( NULL);268 DynLink(true); 237 269 SetReady(); 238 270 break; … … 243 275 244 276 case 5101 : 277 SetBusy(); 245 278 if (data) OpenImage(pfc->GetFileName()); 246 279 SetReady(); … … 248 281 249 282 case 5103 : 250 if (data) SaveCurrent(pfc->GetFileName()); 283 SetBusy(); 284 if (data) SaveCurrentImg(pfc->GetFileName()); 251 285 SetReady(); 252 286 break; 253 254 case 10201 : 255 if ( CurrentPIImage() ) mLutw->Show(); 256 break; 257 258 case 10202 : 259 if ( CurrentPIImage()) 260 { 261 CurrentPIImage()->SetZoom(1, false); 262 CurrentPIImage()->SetOffset(0, 0, false); 263 CurrentImgWin()->SetSize(CurrentImage()->XSize(), 264 CurrentImage()->YSize()); 265 } 266 break; 267 268 case 10203 : 269 if ( CurrentPIImage()) 270 { 271 CurrentPIImage()->SetZoom(2, false); 272 CurrentPIImage()->SetOffset(0, 0, false); 273 CurrentImgWin()->SetSize(CurrentImage()->XSize()*2, 274 CurrentImage()->YSize()*2); 275 } 276 break; 277 278 case 10204 : 279 if ( CurrentPIImage()) 280 { 281 CurrentPIImage()->SetZoom(-2, false); 282 CurrentPIImage()->SetOffset(0, 0, false); 283 CurrentImgWin()->SetSize(CurrentImage()->XSize()/2, 284 CurrentImage()->YSize()/2); 285 } 286 break; 287 } 288 return; 289 } 290 291 /* --Methode-- */ 292 void PIDemoApp::MBProcess2(long msg, PIMsgHandler* /*sender*/, void* /*data*/) 293 { 294 int snx,sny,sx,sy,zm,wt; 295 296 if (CurrentPIImage() == NULL) return; 297 wt = GetCurrentWType(); 298 if ( (wt<1) || (wt>9) ) return; 299 300 switch (msg) 301 { 302 case 10221 : 303 mLutw->Show(); 304 break; 305 306 case 10222 : 307 CurrentPIImage()->Lut()->Print(); 308 break; 309 310 case 10231 : 311 CurrentPIImage()->ShowCursor(false); 312 break; 313 314 case 10232 : 315 CurrentPIImage()->ShowCursor(true); 316 break; 317 318 case 10211 : 319 case 10212 : 320 case 10214 : 321 case 10208 : 322 case 10206 : 323 SetBusy(); 324 if (wt > 3) return; 325 zm = msg-10210; 326 CurrentPIImage()->SetZoom(zm, false); 327 sx = CurrentWindow()->XSize(); 328 sy = CurrentWindow()->YSize(); 329 if (zm > 0) 330 { 331 snx = CurrentImage()->XSize()*zm; 332 sny = CurrentImage()->YSize()*zm; 333 } 334 else 335 { 336 snx = CurrentImage()->XSize()/(-zm); 337 sny = CurrentImage()->YSize()/(-zm); 338 } 339 if ((snx != sx) || (sny != sy)) 340 { 341 CurrentPIImage()->SetOffset(0, 0, false); 342 CurrentWindow()->SetSize(snx, sny); 343 } 344 else CurrentPIImage()->SetOffset(0, 0); 345 SetReady(); 346 break; 347 348 default: 349 printf("PIDemoApp::MBProcess2() BUG?? Msg %d \n", (int)msg); 350 break; 351 352 } 353 287 354 288 case 10205 : 289 if ( CurrentPIImage()) 290 { 291 CurrentPIImage()->SetZoom(4, false); 292 CurrentPIImage()->SetOffset(0, 0, false); 293 CurrentImgWin()->SetSize(CurrentImage()->XSize()*4, 294 CurrentImage()->YSize()*4); 295 } 296 break; 297 298 case 10206 : 299 if ( CurrentPIImage()) 300 { 301 CurrentPIImage()->SetZoom(-4, false); 302 CurrentPIImage()->SetOffset(0, 0); 303 CurrentImgWin()->SetSize(CurrentImage()->XSize()/4, 304 CurrentImage()->YSize()/4); 305 } 306 break; 307 308 309 case 10301: 310 case 10302: 311 case 10303: 312 if ( CurrentPIImage() ) 313 { 314 SetBlocked(); 315 mUP->SelectUP(msg-10300); 316 mUP->Show(); 317 } 318 break; 355 } 356 357 /* --Methode-- */ 358 void PIDemoApp::MBProcess3(long msg, PIMsgHandler* /*sender*/, void* /*data*/) 359 { 360 ImageR4 * pim; 361 Histo * pixelhis; 362 float xmn, xmx, vmn, vsg; 363 int k; 364 365 if (CurrentPIImage() == NULL) return; 366 367 switch (msg) 368 { 369 case 10301: 370 case 10302: 371 case 10303: 372 mUP->SelectUP(msg-10300); 373 mUP->Show(); 374 break; 319 375 320 case 10304: 321 pixelHisto->Zero(); 322 for (int i=0; i<CurrentImage()->XSize(); i++) 323 for (int j=0; j<CurrentImage()->YSize(); j++) 324 pixelHisto->Add((*CurrentImage())(i,j)); 325 piHisto->Refresh(); 326 draw->Show(); 327 break; 328 329 case 10305: 330 if ( CurrentPIImage() ) 331 (CurrentPIImage()->Lut())->Print(); 332 break; 333 334 case 10306: 335 if ( CurrentPIImage() ) 336 { 337 SetBusy(); 338 CurrentImage()->CheckDyn(); 339 CurrentImage()->Print(); 340 SetReady(); 341 } 342 break; 343 344 345 } 346 } 347 } 348 349 /* --Methode-- */ 350 void PIDemoApp::SetBusy() 351 { 352 mState = 2; 353 // lab->SetLabel("Working ..."); 354 } 355 356 /* --Methode-- */ 357 void PIDemoApp::SetReady() 358 { 359 mState = 0; 360 // lab->SetLabel("**Ready**"); 361 } 362 363 /* --Methode-- */ 364 void PIDemoApp::SetBlocked() 365 { 366 mState = 1; 367 // lab->SetLabel("--Dialog--"); 368 } 376 case 10331: 377 SetBusy(); 378 pim = (ImageR4 *)CurrentImage(); 379 if (his_ckd) 380 { 381 pim->MoySigma(vmn, vsg, his_min, his_max, 5); 382 // pim->Print(); 383 xmn = vmn-4.*vsg; xmx = vmn+4.*vsg; 384 if (xmn < his_min) xmn = his_min; 385 if (xmx > his_max) xmx = his_max; 386 } 387 else { xmn=his_min; xmx = his_max; } 388 if ((xmx-xmn) < 1.e-6) xmx = xmn+1.e-3; 389 pixelhis = new Histo(xmn, xmx, his_nbin); 390 for (k=0; k<pim->XSize()*pim->YSize(); k++) 391 pixelhis->Add((*pim)[k]); 392 AddHisto(pixelhis); 393 SetReady(); 394 break; 395 396 case 10332: 397 SetBusy(); 398 printf("\n --- Info (Dynamique) de l'image %s ---- \n", 399 CurrentPIImage()->Nom().c_str()); 400 CurrentImage()->CheckDyn((double)mdynccd->MinADU, (double)mdynccd->MaxADU); 401 CurrentImage()->Print(); 402 SetReady(); 403 break; 404 405 default: 406 printf("PIDemoApp::MBProcess3() BUG?? Msg %d \n", (int)msg); 407 break; 408 409 } 410 411 } 412 413 /* --Methode-- */ 414 void PIDemoApp::MBProcess4(long msg, PIMsgHandler* /*sender*/, void* /*data*/) 415 { 416 ImageR4 * pim; 417 Histo * pixelhis; 418 float xmn, xmx, vmn, vsg; 419 int zm, k; 420 int dx, dy; 421 float xc, yc; 422 char strg[128]; 423 string s; 424 bool keep=false; 425 426 if (CurrentPIImage() == NULL) return; 427 428 if (rect_pav) 429 { 430 dx = CurrentPIImage()->XSzPave(); 431 dy = CurrentPIImage()->YSzPave(); 432 } 433 else { dx = dy = pav_sz; } 434 435 xc = CurrentPIImage()->XPave()+0.5; 436 yc = CurrentPIImage()->YPave()+0.5; 437 438 pim = NULL; 439 pim = new ImageR4(dx, dy); 440 keep = false; 441 CopiePave((ImageR4 &)(*pim), (ImageR4 &)(*CurrentImage()), xc, yc); 442 443 switch (msg) 444 { 445 case 10401: 446 sprintf(strg,"P(%d,%d)%s",CurrentPIImage()->XPave(), 447 CurrentPIImage()->YPave(),CurrentPIImage()->Nom().c_str()); 448 strg[32] = '\0'; 449 zm = vis_zoom+1; 450 if (zm == 0) zm = 1; 451 AddImage(pim, strg, zm); 452 keep = true; 453 break; 454 455 case 10410: 456 if (mTCId != 2) { mVisTC->Hide(); mCutTC->Show(); mTCId = 2; } 457 break; 458 459 case 10420: 460 SetBusy(); 461 keep = FitPSF_Res(pim); 462 SetReady(); 463 break; 464 465 case 10431: 466 SetBusy(); 467 if (his_ckd) 468 { 469 pim->MoySigma(vmn, vsg, his_min, his_max, 2); 470 // pim->Print(); 471 xmn = vmn-4.*vsg; xmx = vmn+4.*vsg; 472 if (xmn < his_min) xmn = his_min; 473 if (xmx > his_max) xmx = his_max; 474 } 475 else { xmn=his_min; xmx = his_max; } 476 if ((xmx-xmn) < 1.e-6) xmx = xmn+1.e-3; 477 pixelhis = new Histo(xmn, xmx, his_nbin); 478 for (k=0; k<pim->XSize()*pim->YSize(); k++) 479 pixelhis->Add((*pim)[k]); 480 AddHisto(pixelhis); 481 SetReady(); 482 break; 483 484 case 10432: 485 SetBusy(); 486 pim->CheckDyn((double)mdynccd->MinADU, (double)mdynccd->MaxADU); 487 printf("\n --- Pave en (%d,%d) de l'image %s ---- \n", 488 CurrentPIImage()->XPave(), CurrentPIImage()->YPave(), 489 CurrentPIImage()->Nom().c_str()); 490 if (prt_pval) 491 pim->PrintImage(); 492 else pim->Print(); 493 SetReady(); 494 break; 495 496 default: 497 printf("PIDemoApp::MBProcess4() BUG?? Msg %d \n", (int)msg); 498 break; 499 500 } 501 502 if (!keep) delete pim; 503 return; 504 } 505 506 /* --Methode-- */ 507 bool PIDemoApp::FitPSF_Res(ImageR4 *pim) 508 { 509 ImageR4 *nois, *resid, *pav; 510 PIImage *pii[2]; 511 PILabel *lab[2]; 512 PIWindow *win; 513 int rc; 514 515 if (pim == NULL) return(false); 516 517 nois = resid = pav = 0; 518 if(typ_psf<1 || typ_psf>4) typ_psf = 1; 519 PSF mypsf(typ_psf,100.0); 520 521 TIMEF 522 printf("\n -------- Resultat PIDemoApp::FitPSF_Res() ----------- \n"); 523 524 pav = pim; 525 nois = NoiseImage(pav, mdynccd); 526 PSFStar mypsfstar(&mypsf); 527 rc = mypsfstar.IniFit(*pav, *nois); 528 if(rc!=0) 529 { 530 printf("PIDemoApp::FitPSF_Res(), Echec IniFit (rc= %d) \n", rc); 531 delete nois; return(false); 532 } 533 rc = mypsfstar.Fit(*pav, *nois); 534 if(rc!=0) 535 { 536 printf("PIDemoApp::FitPSF_Res(), Echec Fit (rc= %d) \n", rc); 537 delete nois; return(false); 538 } 539 540 mypsfstar.Print(2); 541 542 float smax,axisrat,tiltdeg; 543 rc = paramga((float) mypsfstar.SigX(),(float) mypsfstar.SigY() 544 ,(float) mypsfstar.Rho(),&smax,&axisrat,&tiltdeg); 545 if(rc==0) 546 printf("... sa=%g sb=%g (%g) teta=%g\n", 547 smax,smax*axisrat,axisrat,tiltdeg); 548 else puts("Erreur paramga "); 549 550 resid = new ImageR4(pav->XSize(), pav->YSize()); 551 CopieImage((ImageR4 &)(*resid), (ImageR4 &)(*pav)); 552 *resid -= mypsfstar; 553 554 SPLITTIME 555 556 char strg[256]; 557 sprintf(strg, "FitPSF Pave[%d %d]_%s" ,CurrentPIImage()->XPave(), 558 CurrentPIImage()->YPave(),CurrentPIImage()->Nom().c_str()); 559 560 if ((win=GetWindow(340,230,9,strg)) == NULL) 561 { delete nois; delete resid; 562 return(false); } 563 564 lab[0] = new PILabel(win, "Info1", 330, 25, 5, 5); 565 sprintf(strg,"Sx= %5.2f Sy= %5.2f Rho=%4.2f Xi2Fit= %g", 566 (float)mypsfstar.SigX(),(float) mypsfstar.SigY(), 567 (float)mypsfstar.Rho(), mypsfstar.Xi2()); 568 lab[0]->SetLabel((string)strg); 569 lab[1] = new PILabel(win, "Info2", 330, 25, 5, 35); 570 sprintf(strg,"Sa= %5.2f Sb= %5.2f Tet= %5.1f deg", 571 smax, smax*axisrat, tiltdeg); 572 lab[1]->SetLabel((string)strg); 573 574 int zm; 575 zm = 150/pav->XSize(); 576 if (zm < 1) zm = 1; 577 578 else zm++; 579 580 for(int i=0; i<2; i++) 581 { 582 pii[i] = new PIImage(win, "Pave", 160, 160, 5+170*i, 65); 583 pii[i]->SetBinding(true, true, true, true); 584 pii[i]->SetZoomWin(zoom); 585 pii[i]->SetTextWin(labimg); 586 pii[i]->SetZoom(zm, false); 587 pii[i]->SetAutoDelImage(true); 588 pii[i]->ShowCursor(false); 589 } 590 591 pii[0]->SetImage(pav); 592 pii[1]->SetImage(resid); 593 594 delete nois; 595 return(true); 596 } 597 598 369 599 370 600 /* --Methode-- */ … … 377 607 FitsImageR4 * myimg; 378 608 379 if (mNimg >= NMXIMG) 380 { 381 printf("PIDemoApp::OpenImage_Error Two many images (%d) opened ...\n",mNimg); 609 TIMEF 610 611 if (mNwin >= NMXWIN) 612 { 613 printf("PIDemoApp::OpenImage_Error Two many images (%d) opened ...\n",mNwin); 382 614 printf(" Close some of the images ... "); 383 615 return; … … 406 638 { 407 639 string s(buff); 408 AddImage(myimg, s );409 } 410 } 411 412 /* --Methode-- */ 413 void PIDemoApp::AddImage( FitsImageR4 * nouv, string const & name)414 { 415 int nimg = mNimg;640 AddImage(myimg, s, 0, 1); 641 } 642 } 643 644 /* --Methode-- */ 645 void PIDemoApp::AddImage(ImageR4 * nouv, string const & name, int zm, int typ) 646 { 647 PIImage *pii; 416 648 int sx, sy; 417 649 … … 421 653 return; 422 654 } 423 if (mN img >= NMXIMG)424 { 425 printf("PIDemoApp::AddImage_Error T wo many images (%d) opened ...\n",mNimg);426 printf(" Close some of the images ... ");655 if (mNwin >= NMXWIN) 656 { 657 printf("PIDemoApp::AddImage_Error Too many (%d) opened windows...\n",mNwin); 658 printf(" Close some of the windows ... "); 427 659 return; 428 660 } 429 661 430 img[nimg] = nouv; 431 if ( (img[nimg]->XSize() <= 0) || (img[nimg]->YSize() <= 0)) 432 { 433 printf("PIDemoApp::OpenImage_Error Pb lecture (FitsImage::Read) \n"); 662 if ( (nouv->XSize() <= 0) || (nouv->YSize() <= 0)) 663 { 664 printf("PIDemoApp::AddImage_Error Pb lecture (FitsImage::Read ?) \n"); 434 665 return; 435 666 } 436 667 437 sx = img[nimg]->XSize(); sy = img[nimg]->YSize(); 668 if (zm == 0) zm = vis_zoom; 669 sx = nouv->XSize()*zm; sy = nouv->YSize()*zm; 438 670 if (sx > 512) sx = 512; 439 671 if (sy > 512) sy = 512; 440 672 441 wpii[nimg] = new PIWindow(this, (char *)name.c_str(), PIWK_normal,673 awp[mNwin] = new PIWindow(this, (char *)name.c_str(), PIWK_normal, 442 674 sx, sy, 200, 200); 443 pii[nimg] = new PIImage(wpii[nimg], (char *)name.c_str(), sx, sy, 0, 0); 444 pii[nimg]->SetBinding(true, true, true, true); 445 pii[nimg]->SetZoomWin(zoom); 446 pii[nimg]->SetTextWin(labimg); 447 pii[nimg]->SetImage(img[nimg]); 448 // pii[nimg]->Apply(); 449 wpii[nimg]->Show(); 450 mCur = pii[nimg]; 451 mNimg++; 675 pii = new PIImage(awp[mNwin], (char *)name.c_str(), sx, sy, 0, 0); 676 pii->SetBinding(true, true, true, true); 677 pii->SetZoomWin(zoom); 678 pii->SetTextWin(labimg); 679 pii->SetZoom(zm, false); 680 pii->SetAutoDelImage(true); 681 pii->ShowCursor(vis_cursshow); 682 pii->SetImage(nouv); 683 awp[mNwin]->SetAutoDelChilds(true); 684 awp[mNwin]->Show(); 685 if ((typ < 0) || (typ > 9)) typ = 3; 686 taw[mNwin] = typ; 687 mNwin++; mTnw++; 452 688 return; 453 689 } 690 691 692 /* --Methode-- */ 693 void PIDemoApp::AddHisto(Histo *h) 694 { 695 PIDrawWindow * draw = NULL; 696 PIHisto *pih; 697 char strg[64]; 698 699 if (h == NULL) 700 { 701 printf("PIDemoApp::AddHisto_Error Cannot Add NULL Histo \n"); 702 return; 703 } 704 if (mNwin >= NMXWIN) 705 { 706 printf("PIDemoApp::AddHisto_Error Too many (%d) opened windows...\n",mNwin); 707 printf(" Close some of the windows ... "); 708 return; 709 } 710 711 mTnw++; 712 sprintf(strg,"Histo (W %d)",mTnw); 713 draw = new PIDrawWindow(this, strg, PIWK_normal, 300, 300, 300, 300); 714 pih = new PIHisto(h); 715 pih->SetAutoDelHisto(true); 716 draw->AddDrawer(pih); 717 draw->DrawWdg()->SetTextWin(labdrw); 718 awp[mNwin] = draw; 719 draw->Show(); 720 draw->SetAutoDelChilds(true); 721 taw[mNwin] = 10; 722 mNwin++; 723 return; 724 } 725 454 726 455 727 /* --Methode-- */ … … 458 730 int n; 459 731 if ((n=GetNumCurrent()) < 0) return; 460 zoom->SetPixmap(NULL,0,0); 461 zoom->EraseWindow(); 462 labimg->SetLabel(""); 463 wpii[n]->Hide(); 464 delete pii[n]; 465 delete img[n]; 466 delete wpii[n]; 467 pii[n] = pii[mNimg-1]; 468 wpii[n] = wpii[mNimg-1]; 469 img[n] = img[mNimg-1]; 470 mNimg--; 471 mCur = NULL; 732 if ((taw[n] > 0) && (taw[n] < 10)) 733 { 734 zoom->SetPixmap(NULL,0,0); 735 zoom->EraseWindow(); 736 labimg->SetLabel(""); 737 mCurPII = NULL; 738 } 739 else if ((taw[n] > 9) && (taw[n] < 20)) 740 labdrw->SetLabel(""); 741 742 awp[n]->Hide(); 743 delete awp[n]; 744 awp[n] = awp[mNwin-1]; 745 taw[n] = taw[mNwin-1]; 746 mNwin--; 747 mCurWin = NULL; 472 748 return; 473 749 } 474 750 475 751 /* --Methode-- */ 476 void PIDemoApp::SaveCurrent(string const & flnm) 477 { 478 int n; 479 if ((n=GetNumCurrent()) < 0) return; 480 752 void PIDemoApp::SaveCurrentImg(string const & flnm) 753 { 754 FitsImageR4 *pim = NULL; 755 bool fgcr=false; 756 757 if (CurrentImage() == NULL) return; 481 758 if (strlen(flnm.c_str()) <= 0) 482 759 { … … 486 763 487 764 printf("PIDemoApp::SaveCurrent: Image %s saved to %s \n", 488 (char *)pii[n]->Nom().c_str(), (char *)flnm.c_str()); 765 (char *)CurrentPIImage()->Nom().c_str(), (char *)flnm.c_str()); 766 /* $CHECK$ Ca ne marche pas ??? pb avec IsFits() 767 if (CurrentImage()->IsFits()) */ 768 if (GetCurrentWType() == 1) 769 { pim = (FitsImageR4 *) CurrentImage(); 770 fgcr = false; } 771 else 772 { pim = new FitsImageR4(*CurrentImage(),1); 773 fgcr = true; } 774 775 489 776 TRY { 490 img[n]->Save(flnm);777 pim->Save(flnm); 491 778 } CATCH(merr) 492 { printf("PIDemoApp::SaveCurrent_Error Exception= %d (%s) \n", merr, PeidaExc(merr)); } ENDTRY; 779 { 780 printf("PIDemoApp::SaveCurrent_Error Exception= %d (%s) \n", merr, PeidaExc(merr)); 781 if (fgcr) { delete pim; fgcr=false; } 782 } ENDTRY; 783 784 if (fgcr) delete pim; 493 785 return; 494 786 } … … 498 790 { 499 791 int n=-1; 500 if (mN img<= 0) return(-1);501 for(int i=0; i<mN img; i++)502 if (mCur == pii[i]) { n = i; break; }792 if (mNwin <= 0) return(-1); 793 for(int i=0; i<mNwin; i++) 794 if (mCurWin == awp[i]) { n = i; break; } 503 795 504 796 if (n < 0) 505 printf(" PIDemoApp::GetNum Img() Curret image not found (%lx)\n",(long)mCur);797 printf(" PIDemoApp::GetNumCurrent() Current Window not found (%lx)\n",(long)mCurWin); 506 798 507 799 return(n); … … 509 801 510 802 /* --Methode-- */ 511 FitsImageR4 * PIDemoApp::CurrentImage() 512 { 513 int n; 514 n = GetNumCurrent(); 515 if (n < 0) return(NULL); 516 else return(img[n]); 517 } 518 519 /* --Methode-- */ 520 PIWindow * PIDemoApp::CurrentImgWin() 521 { 522 int n; 523 n = GetNumCurrent(); 524 if (n < 0) return(NULL); 525 else return(wpii[n]); 803 int PIDemoApp::GetCurrentWType() 804 { 805 int k; 806 k = GetNumCurrent(); 807 if (k < 0) return(0); 808 else return(taw[k]); 809 } 810 811 /* --Methode-- */ 812 ImageR4 * PIDemoApp::CurrentImage() 813 { 814 if (mCurPII == NULL) return(NULL); 815 return((ImageR4 *)mCurPII->Image()); 816 } 817 818 /* --Methode-- */ 819 PIWindow * PIDemoApp::GetWindow(int sx, int sy, int typ, char * nom) 820 { 821 PIWindow * win = NULL; 822 823 if (mNwin >= NMXWIN) 824 { 825 printf("PIDemoApp::GetWindow_Error Too many (%d) opened windows...\n",mNwin); 826 printf(" Close some of the windows ... "); 827 return(win); 828 } 829 830 awp[mNwin] = new PIWindow(this, nom, PIWK_normal, 831 sx, sy, 250, 250); 832 awp[mNwin]->SetAutoDelChilds(true); 833 taw[mNwin] = typ; 834 win = awp[mNwin]; 835 win->Show(); 836 mNwin++; 837 return(win); 838 } 839 840 841 842 /* ........................................................... */ 843 /* Classe VisuTools (Controle de visualisation) */ 844 /* ........................................................... */ 845 846 VisuTools::VisuTools(PIDemoApp *par, PIContainer *pw) 847 : PIContainer(pw, "visutools", 200, 160, 185, 5) 848 { 849 dap = par; 850 mTlb = new PILabel(this, "VisuTools", 100, 25, 50, 5); 851 852 mOlb[0] = new PILabel(this, "AutoLut :", 70, 25, 5, 45); 853 mPum[0] = new PIPUMenu((PIMsgHandler *)this, "AutoLut"); 854 mPum[0]->AppendItem("+3 Sig", 303); 855 mPum[0]->AppendItem("+2 Sig", 302); 856 mPum[0]->AppendItem("+1 Sig", 301); 857 mPum[0]->AppendItem("-1 Sig", 299); 858 mPum[0]->AppendItem("-2 Sig", 298); 859 mOpt[0] = new PIOptMenu(this, mPum[0], 90, 25, 80, 45); 860 mOpt[0]->SetValue(302); 861 862 mOlb[1] = new PILabel(this, "Zoom :", 70, 25, 5, 85); 863 mPum[1] = new PIPUMenu((PIMsgHandler *)this, "Zoom"); 864 mPum[1]->AppendItem("Agr. * 8", 108); 865 mPum[1]->AppendItem("Agr. * 6", 106); 866 mPum[1]->AppendItem("Agr. * 5", 105); 867 mPum[1]->AppendItem("Agr. * 4", 104); 868 mPum[1]->AppendItem("Agr. * 3", 103); 869 mPum[1]->AppendItem("Agr. * 2", 102); 870 mPum[1]->AppendItem("* 1", 101); 871 mPum[1]->AppendItem("Red. / 2", 98); 872 mPum[1]->AppendItem("Red. / 3", 97); 873 mPum[1]->AppendItem("Red. / 4", 96); 874 mPum[1]->AppendItem("Red. / 5", 95); 875 mPum[1]->AppendItem("Red. / 6", 94); 876 mPum[1]->AppendItem("Red. / 8", 92); 877 mOpt[1] = new PIOptMenu(this, mPum[1], 90, 25, 80, 85); 878 mOpt[1]->SetValue(101); 879 880 mOlb[2] = new PILabel(this, "ColMap :", 70, 25, 5, 125); 881 mPum[2] = new PIPUMenu((PIMsgHandler *)this, "ColMap"); 882 mPum[2]->AppendItem("Grey32", 201); 883 mPum[2]->AppendItem("GreyInv32", 202); 884 mPum[2]->AppendItem("ColRJ32", 203); 885 mPum[2]->AppendItem("ColBR32", 204); 886 mPum[2]->AppendItem("ColRV32", 205); 887 mOpt[2] = new PIOptMenu(this, mPum[2], 90, 25, 80, 125); 888 mOpt[2]->SetValue(203); 889 890 FinishCreate(); 891 } 892 893 894 /* --Methode-- */ 895 VisuTools::~VisuTools() 896 { 897 898 delete mTlb; 899 for(int i=0; i<3; i++) 900 { 901 delete mOpt[i]; 902 delete mPum[i]; 903 delete mOlb[i]; 904 } 905 } 906 907 /* --Methode-- */ 908 void VisuTools::Process(long msg, PIMsgHandler* /*sender*/, void* /*data*/) 909 { 910 CMapId cmap[5] = { CMAP_GREY32, CMAP_GREYINV32, CMAP_COLRJ32, 911 CMAP_COLBR32, CMAP_COLRV32 } ; 912 913 if (dap->CurrentPIImage() == NULL) return; 914 dap->SetBusy(); 915 if ((msg < 110) && (msg > 90)) // Zoom 916 dap->CurrentPIImage()->SetZoom((int)(msg-100)); 917 else if ((msg > 200) && (msg < 206)) // Changement de couleur 918 dap->CurrentPIImage()->SetColMap(cmap[msg-201]); 919 else if ((msg > 290) && (msg < 310)) 920 dap->CurrentPIImage()->SetLut( dap->CurrentImage()->minPix, dap->CurrentImage()->maxPix, 921 kLutType_Lin, msg-300); 922 dap->SetReady(); 923 return; 924 } 925 926 927 /* ........................................................... */ 928 /* Classe CutTools (Controle de coupe) */ 929 /* ........................................................... */ 930 931 /* --Methode-- */ 932 CutTools::CutTools(PIDemoApp *par, PIContainer *pw) 933 : PIContainer(pw, "cuttools", 200, 160, 185, 5) 934 { 935 int i; 936 937 dap = par; 938 939 mOlb = new PILabel(this, "Coupe:", 70, 25, 5, 5); 940 mPum = new PIPUMenu((PIMsgHandler *)this, "Coupe"); 941 mPum->AppendItem("H-V", 101); 942 mPum->AppendItem("Diagonal", 102); 943 mOpt = new PIOptMenu(this, mPum, 90, 25, 80, 5); 944 mOpt->SetValue(101); 945 946 mBut[0] = new PIButton(this, "Y-", 501, 30, 25, 85, 60); 947 mBut[1] = new PIButton(this, "Y+", 502, 30, 25, 85, 120); 948 mBut[2] = new PIButton(this, "X-", 503, 30, 25, 50, 90); 949 mBut[3] = new PIButton(this, "X+", 504, 30, 25, 120, 90); 950 951 fgpb = true; 952 fgdiag = false; 953 954 for(i=0; i<2; i++) 955 { mDrw[i] = NULL; mPIH[i] = NULL; } 956 957 FinishCreate(); 958 959 } 960 961 962 /* --Methode-- */ 963 CutTools::~CutTools() 964 { 965 int i; 966 967 for(i=0; i<4; i++) delete mBut[i]; 968 delete mOpt; 969 delete mPum; 970 delete mOlb; 971 } 972 973 /* --Methode-- */ 974 void CutTools::Show() 975 { 976 PIWindow *win; 977 978 PIContainer::Show(); 979 fgpb = true; 980 981 if (dap->CurrentPIImage() == NULL) return; 982 if (dap->CurrentImage() == NULL) return; 983 984 mPx = dap->CurrentPIImage()->XPave(); 985 mPy = dap->CurrentPIImage()->YPave(); 986 if (rect_pav) 987 { 988 mDx = dap->CurrentPIImage()->XSzPave(); 989 mDy = dap->CurrentPIImage()->YSzPave(); 990 } 991 else { mDx = mDy = pav_sz; } 992 if( mDx%2 == 0 ) mDx++; 993 if( mDy%2 == 0 ) mDy++; 994 mDxy = ( mDx > mDy ) ? mDx : mDy; 995 996 997 char strg[128]; 998 sprintf(strg, "Coupe Pave_%s" ,dap->CurrentPIImage()->Nom().c_str()); 999 1000 if ((win=dap->GetWindow(600,330,12,strg)) == NULL) 1001 { fgpb=true; return; } 1002 mLab = new PILabel(win, "infc", 590, 25, 5, 5); 1003 for(int i=0; i<2; i++) 1004 { 1005 mDrw[i] = new PIScDrawWdg(win, "Coupe", 300, 300, 300*i, 30); 1006 mPIH[i] = NULL; 1007 } 1008 fgpb = false; 1009 FillHistos(); 1010 return; 1011 } 1012 1013 1014 /* --Methode-- */ 1015 void CutTools::Process(long msg, PIMsgHandler* /*sender*/, void* /*data*/) 1016 { 1017 if ((fgpb) || (dap->CurrentPIImage() == NULL)) 1018 { printf("CutTools::Process, Msg= %d , --PB--\n", (int)msg); 1019 return; } 1020 1021 1022 switch(msg) 1023 { 1024 case 101: 1025 if (fgdiag) 1026 { fgdiag = false; FillHistos(); } 1027 break; 1028 1029 case 102: 1030 if (!fgdiag) 1031 { fgdiag = true; FillHistos(); } 1032 break; 1033 1034 case 501: 1035 case 502: 1036 case 503: 1037 case 504: 1038 switch(msg) 1039 { 1040 case 501: 1041 mPy--; 1042 break; 1043 case 502: 1044 mPy++; 1045 break; 1046 case 503: 1047 mPx--; 1048 break; 1049 case 504: 1050 mPx++; 1051 break; 1052 } 1053 dap->CurrentPIImage()->SetPave(mPx, mPy); 1054 mPx = dap->CurrentPIImage()->XPave(); 1055 mPy = dap->CurrentPIImage()->YPave(); 1056 FillHistos(); 1057 break; 1058 1059 default: 1060 printf("CutTools::Process/BUG ??? Msg = %d \n", (int)msg); 1061 break; 1062 } 1063 return; 1064 } 1065 1066 /* --Methode-- */ 1067 void CutTools::FillHistos() 1068 { 1069 int i; 1070 int xp,yp; 1071 int dx,dy,dxy; 1072 Histo * his[2]; 1073 float xmin,xmax; 1074 int ip,jp,imax,jmax; 1075 ImageR4 *myimg; 1076 char buff[256]; 1077 char *txt[2] = {"H-V ","Diag"}; 1078 1079 xp = mPx; yp = mPy; 1080 dx = mDx; dy = mDy; dxy = mDxy; 1081 1082 myimg = dap->CurrentImage(); 1083 1084 /* Recherche du pixel maxi */ 1085 imax = xp; 1086 jmax = yp; 1087 xmax = (float) (*myimg)(imax,jmax); 1088 for(i=0;i<dx;i++) { 1089 ip = xp -(dx-1)/2 + i; 1090 if( ip < 0 || ip >= myimg->XSize() ) continue; 1091 for(int j=0;j<dy;j++) { 1092 jp = yp -(dy-1)/2 + j; 1093 if( jp < 0 || jp >= myimg->YSize() ) continue; 1094 if( (float) (*myimg)(ip,jp) < xmax ) continue; 1095 imax = ip; 1096 jmax = jp; 1097 xmax = (float) (*myimg)(imax,jmax); 1098 } 1099 } 1100 1101 i = (fgdiag) ? 1 : 0; 1102 sprintf(buff,"Coupe %s en (%d %d) PixMax= %g en (%d %d)", 1103 txt[i], xp, yp, xmax, imax, jmax); 1104 mLab->SetLabel((string)buff); 1105 1106 for(i=0; i<2; i++) delete mPIH[i]; 1107 1108 if (!fgdiag) // Histos H-V 1109 { 1110 xmin = (float) (xp - (dx-1)/2) - 0.5; 1111 xmax = (float) (xp + (dx-1)/2) + 0.5; 1112 his[0] = new Histo(xmin,xmax,dx); 1113 xmin = (float) (yp - (dy-1)/2) - 0.5; 1114 xmax = (float) (yp + (dy-1)/2) + 0.5; 1115 his[1] = new Histo(xmin,xmax,dy); 1116 1117 for(i=0;i<dx;i++) { 1118 ip = xp -(dx-1)/2 + i; 1119 if( ip < 0 || ip >= myimg->XSize() ) continue; 1120 his[0]->Add((float) ip,(float) (*myimg)(ip,yp)); 1121 } 1122 for(i=0;i<dy;i++) { 1123 ip = yp -(dy-1)/2 + i; 1124 if( ip < 0 || ip >= myimg->YSize() ) continue; 1125 his[1]->Add((float) ip,(float) (*myimg)(xp,ip)); 1126 } 1127 } 1128 else // Histo diagonals.... 1129 { 1130 xmin = (float) -(dxy-1)/2 - 0.5; 1131 xmax = (float) (dxy-1)/2 + 0.5; 1132 his[0] = new Histo(xmin,xmax,dxy); 1133 his[1] = new Histo(xmin,xmax,dxy); 1134 for(i=0;i<dxy;i++) { 1135 ip = xp -(dxy-1)/2 + i; 1136 jp = yp -(dxy-1)/2 + i; 1137 if( ip < 0 || ip >= myimg->XSize() ) continue; 1138 if( jp >= 0 && jp < myimg->YSize() ) 1139 his[0]->Add((float) ip-xp,(float) (*myimg)(ip,jp)); 1140 jp = yp +(dxy-1)/2 - i; 1141 if( jp >= 0 && jp < myimg->YSize() ) 1142 his[1]->Add((float) ip-xp,(float) (*myimg)(ip,jp)); 1143 } 1144 1145 } 1146 for(i=0; i<2; i++) 1147 { 1148 mPIH[i] = new PIHisto(his[i]); 1149 mPIH[i]->SetAutoDelHisto(true); 1150 mDrw[i]->AddDrawer(mPIH[i]); 1151 mDrw[i]->SetTextWin(dap->DrawLabelWdg()); 1152 mPIH[i]->Refresh(); 1153 } 1154 1155 return; 526 1156 } 527 1157 … … 529 1159 /* Classe LutWind (Changement de Lut d'image) */ 530 1160 /* ........................................................... */ 531 532 533 1161 534 1162 /* --Methode-- */ … … 581 1209 delete mOpt[i]; 582 1210 delete mPum[i]; 1211 delete mOlb[i]; 583 1212 } 584 1213 } … … 597 1226 mOpt[0]->SetValue(1100); 598 1227 else mOpt[0]->SetValue(1101); 599 mOpt[1]->SetValueStr("NoAuto"); 1228 string s("NoAuto"); 1229 mOpt[1]->SetValueStr(s); 600 1230 dap->SetBlocked(); 601 1231 PIWindow::Show(); … … 605 1235 606 1236 /* --Methode-- */ 607 void LutWind::Process(long msg, PIMsgHandler* sender, void* data)1237 void LutWind::Process(long msg, PIMsgHandler* /*sender*/, void* /*data*/) 608 1238 { 609 1239 float min, max; … … 677 1307 678 1308 /* --Methode-- */ 679 void UserProcWind::Process(long msg, PIMsgHandler* sender, void* data) 680 { 681 FitsImageR4 *mimg, *oimg; 1309 void UserProcWind::Show() 1310 { 1311 dap->SetBlocked(); 1312 PIWindow::Show(); 1313 return; 1314 } 1315 1316 1317 /* --Methode-- */ 1318 void UserProcWind::Process(long msg, PIMsgHandler* /*sender*/, void* /*data*/) 1319 { 1320 ImageR4 *mimg, *oimg; 682 1321 int xp, yp, dx, dy; 683 1322 … … 685 1324 { 686 1325 case 2600: 1326 this->Hide(); 687 1327 dap->SetReady(); 688 this->Hide();689 1328 break; 690 1329 691 1330 case 2500: 1331 if ((mUpr < 1) || (mUpr > 3)) mUpr=1; 1332 if (userFunc[mUpr-1] == NULL) 1333 { printf("UserProcWind::Process()/Warning: pas de UserProcFunc%d \n", mUpr); 1334 this->Hide(); dap->SetReady(); return; } 692 1335 mimg = dap->CurrentImage(); 693 1336 if (mimg == NULL) return; … … 696 1339 dx = (dap->CurrentPIImage())->XSzPave(); 697 1340 dy = (dap->CurrentPIImage())->YSzPave(); 1341 this->Hide(); 698 1342 dap->SetBusy(); 699 this->Hide();700 1343 oimg = NULL; 701 1344 switch (mUpr) … … 708 1351 (char *) (mText[2]->GetText().c_str())); 709 1352 break; 710 /*711 case 2 :712 oimg = PIUserProc_2(mimg, xp, yp, dx, dy,713 (char *) (mText[1]->GetText().c_str()),714 (char *) (mText[2]->GetText().c_str()));715 break;716 717 case 3 :718 oimg = PIUserProc_3(mimg, xp, yp, dx, dy,719 (char *) (mText[1]->GetText().c_str()),720 (char *) (mText[2]->GetText().c_str()));721 break;722 */723 1353 } 724 1354 if (oimg) dap->AddImage(oimg,mText[0]->GetText()); … … 732 1362 // Le main .... 733 1363 1364 /* ........................................................... */ 1365 /* Classe OptionWind Options et valeurs de parametres */ 1366 /* ........................................................... */ 1367 1368 1369 /* --Methode-- */ 1370 OptionWind::OptionWind(PIDemoApp *par) 1371 : PIWindow((PIMsgHandler *)par, "Options (PIDemo)", PIWK_dialog, 1372 360, 550, 150, 150) 1373 { 1374 dap = par; 1375 1376 mLab[0] = new PILabel(this, "PaveSz", 60, 30, 20, 60); 1377 1378 mLab[1] = new PILabel(this, "MinADU", 60, 30, 20, 190); 1379 mLab[2] = new PILabel(this, "MaxADU", 60, 30, 185, 190); 1380 mLab[3] = new PILabel(this, "Gain", 60, 30, 20, 230); 1381 mLab[4] = new PILabel(this, "RONoise", 60, 30, 185, 230); 1382 1383 mLab[5] = new PILabel(this, "NBinHis", 60, 30, 20, 320); 1384 mLab[6] = new PILabel(this, "MinHis", 60, 30, 20, 360); 1385 mLab[7] = new PILabel(this, "MaxHis", 60, 30, 185, 360); 1386 1387 mText[0] = new PIText(this, "PaveSz", 90, 30, 85, 60); 1388 mText[0]->SetText("15"); 1389 mText[1] = new PIText(this, "MinADU", 90, 30, 85, 190); 1390 mText[1]->SetText("1."); 1391 mText[2] = new PIText(this, "MaxADU", 90, 30, 250, 190); 1392 mText[2]->SetText("32000."); 1393 mText[3] = new PIText(this, "Gain", 90, 30, 85, 230); 1394 mText[3]->SetText("3."); 1395 mText[4] = new PIText(this, "RONoise", 90, 30, 250, 230); 1396 mText[4]->SetText("10."); 1397 mText[5] = new PIText(this, "NBin", 90, 30, 85, 320); 1398 mText[5]->SetText("200"); 1399 mText[6] = new PIText(this, "MinHis", 90, 30, 85, 360); 1400 mText[6]->SetText("0."); 1401 mText[7] = new PIText(this, "MaxHis", 90, 30, 250, 360); 1402 mText[7]->SetText("2000."); 1403 1404 mTlb[0] = new PILabel(this, "--- Fit/Coupe/PrintPave ---", 160, 25, 100, 20); 1405 mTlb[1] = new PILabel(this, "--- DynCCD ---", 160, 25, 100, 150); 1406 mTlb[2] = new PILabel(this, "--- Histogramme ---", 160, 25, 100, 280); 1407 mTlb[3] = new PILabel(this, "--- Visualisation ---", 160, 25, 100, 410); 1408 1409 mOlb[0] = new PILabel(this, "TypePSF", 60, 25, 20, 100); 1410 mPum[0] = new PIPUMenu((PIMsgHandler *)this, "TypPSF"); 1411 mPum[0]->AppendItem("Gaussienne", 3101); 1412 mPum[0]->AppendItem("Gauss.Int.", 3102); 1413 mPum[0]->AppendItem("DL-Gauss.", 3103); 1414 mPum[0]->AppendItem("DL-GauInt", 3104); 1415 mOpt[0] = new PIOptMenu(this, mPum[0], 90, 25, 85, 100); 1416 mOpt[0]->SetValue(3101); 1417 1418 mOlb[1] = new PILabel(this, "Def.Zoom", 60, 25, 20, 450); 1419 mPum[1] = NULL; 1420 mOpt[1] = new PIOptMenu(this, dap->VisTC()->ZoomOptMenu(), 90, 25, 85, 450); 1421 mOpt[1]->SetValue(101); 1422 1423 mCkb[0] = new PICheckBox(this,"ou Rect.Sel.",3001,140, 30, 200, 60); 1424 mCkb[1] = new PICheckBox(this,"PrintPave-PixVal",3002,140, 30, 200, 100); 1425 mCkb[2] = new PICheckBox(this,"AutoMin/Max",3003,140, 30, 200, 320); 1426 mCkb[3] = new PICheckBox(this,"ShowCursor",3004,140, 30, 200, 450); 1427 for(int i=0; i<4; i++) mCkv[i] = true; 1428 1429 mBut[0] = new PIButton(this, "Apply", 3500, 70, 30, 90, 500); 1430 mBut[1] = new PIButton(this, "Cancel", 3600, 70, 30, 200, 500); 1431 1432 FinishCreate(); 1433 } 1434 1435 /* --Methode-- */ 1436 OptionWind::~OptionWind() 1437 { 1438 int i; 1439 for(i=0; i<2; i++) 1440 { 1441 delete mBut[i]; 1442 delete mOpt[i]; 1443 delete mPum[i]; 1444 delete mOlb[i]; 1445 } 1446 for(i=0; i<8; i++) 1447 { 1448 delete mLab[i]; 1449 delete mText[i]; 1450 } 1451 for(i=0; i<4; i++) 1452 { 1453 delete mTlb[i]; 1454 delete mCkb[i]; 1455 } 1456 } 1457 1458 /* --Methode-- */ 1459 void OptionWind::Show() 1460 { 1461 char buff[64]; 1462 1463 dap->SetBlocked(); 1464 sprintf(buff,"%d", pav_sz); 1465 mText[0]->SetText(buff); 1466 sprintf(buff,"%g", mdynccd->MinADU); 1467 mText[1]->SetText(buff); 1468 sprintf(buff,"%g", mdynccd->MaxADU); 1469 mText[2]->SetText(buff); 1470 sprintf(buff,"%g", mdynccd->Gain); 1471 mText[3]->SetText(buff); 1472 sprintf(buff,"%g", mdynccd->RONoise); 1473 mText[4]->SetText(buff); 1474 sprintf(buff,"%d", his_nbin); 1475 mText[5]->SetText(buff); 1476 sprintf(buff,"%g", his_min); 1477 mText[6]->SetText(buff); 1478 sprintf(buff,"%g", his_max); 1479 mText[7]->SetText(buff); 1480 1481 mOpt[0]->SetValue(3100+typ_psf); 1482 mOpt[1]->SetValue(100+vis_zoom); 1483 mCkv[0] = rect_pav; 1484 mCkv[1] = prt_pval; 1485 mCkv[2] = his_ckd; 1486 mCkv[3] = vis_cursshow; 1487 for(int i=0; i<4; i++) 1488 mCkb[i]->SetState(mCkv[i]); 1489 1490 PIWindow::Show(); 1491 return; 1492 } 1493 1494 1495 /* --Methode-- */ 1496 void OptionWind::Process(long msg, PIMsgHandler* /*sender*/, void* data) 1497 { 1498 1499 switch (msg) 1500 { 1501 case 3001: 1502 case 3002: 1503 case 3003: 1504 case 3004: 1505 if (data) mCkv[msg-3001] = true; // J'ai un pb avec les CheckBox->GetState() Reza ?? 1506 else mCkv[msg-3001] = false; 1507 break; 1508 1509 case 3600: 1510 dap->SetReady(); 1511 this->Hide(); 1512 break; 1513 1514 case 3500: 1515 pav_sz = atoi(mText[0]->GetText().c_str()); 1516 mdynccd->MinADU = atof(mText[1]->GetText().c_str()); 1517 mdynccd->MaxADU = atof(mText[2]->GetText().c_str()); 1518 mdynccd->Gain = atof(mText[3]->GetText().c_str()); 1519 mdynccd->RONoise = atof(mText[4]->GetText().c_str()); 1520 his_nbin = atoi(mText[5]->GetText().c_str()); 1521 his_min = atof(mText[6]->GetText().c_str()); 1522 his_max = atof(mText[7]->GetText().c_str()); 1523 1524 typ_psf = mOpt[0]->GetValue() - 3100; 1525 vis_zoom = mOpt[1]->GetValue() - 100; 1526 1527 /* 1528 Je ne sais pas pourquoi ca ne marche pas comme ca Reza $CHECK$ ??? 1529 rect_pav = mCkb[0]->GetState(); 1530 prt_pval = mCkb[1]->GetState(); 1531 his_ckd = mCkb[2]->GetState(); 1532 vis_cursshow = mCkb[3]->GetState(); 1533 */ 1534 rect_pav = mCkv[0]; 1535 prt_pval = mCkv[1]; 1536 his_ckd = mCkv[2]; 1537 vis_cursshow = mCkv[3]; 1538 /* 1539 printf("\n-- %d %d %d %d -- \n", (int)rect_pav, (int)prt_pval, (int)his_ckd, 1540 (int)vis_cursshow); 1541 printf("OptionWind::Process(OK) : %d %d (%d) %d %g %g - %d \n", 1542 typ_psf, pav_sz, (int)rect_pav, his_nbin, his_min, his_max, vis_zoom); 1543 for(int i=0; i<4; i++) 1544 printf("ckb[%d] = %d (%d) - ", i, (int)mCkb[i]->GetState(),mCkv[i]); 1545 puts(" ... "); 1546 mdynccd->Print(); 1547 */ 1548 dap->SetReady(); 1549 this->Hide(); 1550 1551 break; 1552 default: 1553 // printf("OptionWind::Process Msg %d received data= %ld\n", (int)msg, (long)data); 1554 break; 1555 } 1556 1557 } 1558 1559 734 1560 int main(int narg, char *arg[]) 735 1561 { 736 1562 737 1563 char *path; 738 int rc; 1564 int i, rc, ofa; 1565 char strg[512]; 739 1566 740 1567 PeidaStarRecoInitiator InitStarReco; 741 742 if (narg > 1) path = arg[1]; 743 else path = NULL; 744 745 if (narg > 2) rc = DynLink(arg[2]); 746 else rc = DynLink("piup.so"); 747 if (rc != 0) 748 { 749 printf("PIApp:: Erreur d'ouverture UserProcFunc Shared-Object ... \n"); 750 exit(0); 751 } 752 753 PIDemoApp app(path); 754 755 app.Run(); 756 1568 1569 ofa = 1; path = NULL; 1570 if (narg > 1) 1571 { 1572 if (strcmp(arg[1],"-h") == 0) 1573 { 1574 puts("\n piapp: Programme d analyse interactive EROS-2 (Version demo)"); 1575 puts("Usage: piapp [-p ImagePath] [img1 img2 ...]"); 1576 exit(0); 1577 } 1578 1579 if (strcmp(arg[1],"-p") == 0) 1580 { 1581 if (narg == 2) 1582 { puts("piapp_Erreur: Pb. d argument (piapp -h) "); exit(1); } 1583 else { path = arg[2]; ofa = 3; } 1584 } 1585 } 1586 1587 1588 mdynccd = new DynCCD(1, 1., 32000., 3., 10.); 1589 PIDemoApp * app = new PIDemoApp(path); 1590 app->SetBusy(); 1591 rc = DynLink(false); 1592 for(i=ofa; i<narg; i++) 1593 { 1594 if (path) sprintf(strg,"%s/%s", path, arg[i]); 1595 else strcpy(strg, arg[i]); 1596 string s(strg); 1597 app->OpenImage(s); 1598 } 1599 puts("appel de Application.Run() ... "); 1600 app->SetReady(); 1601 app->Run(); 1602 1603 delete app; 757 1604 dlclose(dlhandle); 758 1605 exit(0); 759 1606 } 1607 1608 -
trunk/SophyaPI/PI/pidemo.h
r8 r18 16 16 17 17 18 #define NMX IMG 15 // Nb maxi d'images ouvertes simultanement18 #define NMXWIN 25 // Nb maxi de fenetres ouvertes simultanement 19 19 20 class VisuTools; 21 class CutTools; 20 22 class LutWind; 21 23 class UserProcWind; 24 class OptionWind; 22 25 23 26 class PIDemoApp : public PIApplication { … … 28 31 virtual void Process(long msg, PIMsgHandler* sender, void* data=NULL); 29 32 30 void SetBusy(); 31 void SetReady(); 32 void SetBlocked(); 33 void AddImage(FitsImageR4 * nouv, string const & name); 33 void AddImage(ImageR4 * nouv, string const & name, int zm=0, int typ=3); 34 void AddHisto(Histo *h); 34 35 void OpenImage(string const & flnm); 35 36 void CloseCurrent(); 36 void SaveCurrent(string const & flnm); 37 int GetNumCurrent(); 38 inline PIImage * CurrentPIImage() { return (mCur); } 39 FitsImageR4 * CurrentImage(); 40 PIWindow * CurrentImgWin(); 37 void SaveCurrentImg(string const & flnm); 38 inline PIImage * CurrentPIImage() { return (mCurPII); } 39 ImageR4 * CurrentImage(); 40 PIWindow * CurrentWindow() { return (mCurWin); }; 41 int GetNumCurrent(); 42 int GetCurrentWType(); 43 44 PIWindow * GetWindow(int sx, int sy, int typ, char * nom); 45 46 inline VisuTools * VisTC() { return mVisTC; } 47 inline CutTools * CutTC() { return mCutTC; } 48 49 inline PILabel * ImagLabelWdg() { return labimg; } 50 inline PILabel * DrawLabelWdg() { return labdrw; } 41 51 42 52 private: 43 PIPDMenu *m[3]; 44 PIPUMenu *pum[3]; 45 PIOptMenu * opm[3]; 46 PILabel *olb[3]; 53 void MBProcess1(long msg, PIMsgHandler* sender, void* data=NULL); 54 void MBProcess2(long msg, PIMsgHandler* sender, void* data=NULL); 55 void MBProcess3(long msg, PIMsgHandler* sender, void* data=NULL); 56 void MBProcess4(long msg, PIMsgHandler* sender, void* data=NULL); 57 bool FitPSF_Res(ImageR4 *pim); 58 59 PIPDMenu *m[5]; 47 60 PIButton * but; 48 61 PIPixmap * zoom; 49 PILabel * labimg, *lab; 62 PILabel * labimg, *labdrw; 63 PILabel *lab, * mTlb[2]; 50 64 PIFileChooser * pfc; 51 65 52 PIDrawWindow * draw; 53 PIHisto * piHisto; 54 Histo* pixelHisto; 55 PIWindow * wpii[NMXIMG]; 56 PIImage * pii[NMXIMG]; 57 FitsImageR4 * img[NMXIMG]; 58 int mNimg; 59 PIImage * mCur; 60 int mState; 66 VisuTools *mVisTC; 67 CutTools *mCutTC; 68 69 int mTCId; 70 71 PIWindow * awp[NMXWIN]; 72 int taw[NMXWIN]; 73 int mNwin,mTnw; 74 PIWindow * mCurWin; 75 PIImage * mCurPII; 61 76 62 77 LutWind * mLutw; 63 78 UserProcWind * mUP; 64 79 OptionWind * mOptw; 65 80 }; 81 82 /* --------------------------------------------------------------------------- */ 83 84 class VisuTools : public PIContainer { 85 public : 86 VisuTools(PIDemoApp *par, PIContainer *pw); 87 ~VisuTools(); 88 virtual void Process(long msg, PIMsgHandler* sender, void* data=NULL); 89 90 PIPUMenu * ZoomOptMenu() { return mPum[1]; } 91 PIPUMenu * LutOptMenu() { return mPum[0]; } 92 PIPUMenu * ColMapOptMenu() { return mPum[2]; } 93 94 private: 95 PIDemoApp * dap; 96 PILabel * mTlb; 97 PIPUMenu * mPum[3]; 98 PIOptMenu * mOpt[3]; 99 PILabel * mOlb[3]; 100 101 }; 102 103 /* --------------------------------------------------------------------------- */ 104 105 class CutTools : public PIContainer { 106 public : 107 CutTools(PIDemoApp *par, PIContainer *pw); 108 ~CutTools(); 109 virtual void Show(); 110 virtual void Process(long msg, PIMsgHandler* sender, void* data=NULL); 111 112 private: 113 void FillHistos(); 114 115 PIDemoApp * dap; 116 PIButton * mBut[4]; 117 PIPUMenu * mPum; 118 PIOptMenu * mOpt; 119 PILabel * mOlb; 120 121 int mDx, mDy, mDxy; 122 int mPx, mPy; 123 124 PIHisto * mPIH[2]; 125 PIScDrawWdg * mDrw[2]; 126 PILabel * mLab; 127 128 bool fgpb; 129 bool fgdiag; 130 131 }; 132 133 134 /* --------------------------------------------------------------------------- */ 66 135 67 136 class LutWind : public PIWindow { … … 83 152 }; 84 153 154 /* --------------------------------------------------------------------------- */ 155 85 156 class UserProcWind : public PIWindow { 86 157 public : 87 158 UserProcWind(PIDemoApp *par); 88 159 ~UserProcWind(); 160 virtual void Show(); 89 161 virtual void Process(long msg, PIMsgHandler* sender, void* data=NULL); 90 162 void SelectUP(int n) { mUpr = n; }; … … 99 171 }; 100 172 173 174 /* --------------------------------------------------------------------------- */ 175 176 class OptionWind : public PIWindow { 177 public : 178 OptionWind(PIDemoApp *par); 179 ~OptionWind(); 180 virtual void Show(); 181 virtual void Process(long msg, PIMsgHandler* sender, void* data=NULL); 182 183 private: 184 PIDemoApp * dap; 185 PILabel * mLab[8]; 186 PIButton * mBut[2]; 187 PIText * mText[8]; 188 PIPUMenu * mPum[2]; 189 PIOptMenu * mOpt[2]; 190 PILabel * mOlb[2]; 191 PILabel * mTlb[4]; 192 PICheckBox * mCkb[4]; 193 bool mCkv[4]; 194 195 }; -
trunk/SophyaPI/PI/pidrawwin.cc
r9 r18 5 5 :PIWindow(par, nom, k, sx, sy, px, py) 6 6 { 7 mDrawWdg = new PIScDrawWdg(this, "", sx-20, sy-20, 10, 10);7 mDrawWdg = new PIScDrawWdg(this, nom, sx-20, sy-20, 10, 10); 8 8 mDrawWdg->SetBinding(true, true, true, true); 9 9 } -
trunk/SophyaPI/PI/pidrawwin.h
r15 r18 17 17 virtual void AddDrawer(PIScDrawer*); 18 18 virtual void SetAxesFlags(int flags=-1); 19 inline PIScDrawWdg * DrawWdg() { return mDrawWdg; } 19 20 private: 20 21 PIScDrawWdg* mDrawWdg; -
trunk/SophyaPI/PI/pifilechox.cc
r6 r18 21 21 pif = (PIFileChooserX *) usd ; 22 22 pif->mSt = 1; 23 pif->MWin()->Unmanage(); 23 24 pif->Send(pif->Msg(), (void *) (pif->GetFileName().c_str())); 24 pif->MWin()->Unmanage();25 25 return; 26 26 } … … 32 32 pif = (PIFileChooserX *) usd ; 33 33 pif->mSt = 0; 34 pif->MWin()->Unmanage(); 34 35 pif->Send(pif->Msg(), NULL); 35 pif->MWin()->Unmanage();36 36 return; 37 37 } -
trunk/SophyaPI/PI/pihisto.cc
r17 r18 5 5 : PIScDrawer(), mHisto(histo) 6 6 { 7 ahisup = false; // Flag pour suppression automatique de mHisto 7 8 } 8 9 9 10 PIHisto::~PIHisto() 10 11 { 12 if (ahisup) 13 delete mHisto; 11 14 } 15 16 void 17 PIHisto::SetAutoDelHisto(bool ad) 18 { 19 ahisup = ad; 20 } 21 12 22 13 23 void -
trunk/SophyaPI/PI/pihisto.h
r9 r18 13 13 virtual void DrawStats(); 14 14 virtual void Refresh(); // Recalcule les limites, et reaffiche 15 void SetAutoDelHisto(bool ad=false); 15 16 protected: 16 17 Histo* mHisto; 18 bool ahisup; 19 17 20 virtual void AttachTo(PIScDrawWdg*); 18 21 virtual void UpdateSize(); -
trunk/SophyaPI/PI/piimage.cc
r15 r18 21 21 22 22 img = NULL; 23 aisup = false; 24 curshow = true; 25 winovis = true; // $CHECK$ Reza A enlever si possible 17/6/96 23 26 zow = NULL; 24 27 txw = NULL; … … 32 35 xmv0 = ymv0 = -1; 33 36 dxmv = dymv = 0; 37 xcurs = ycurs = -1; 34 38 zoom = 1; 35 39 … … 46 50 ActivateMove(3); 47 51 48 49 52 } 50 53 … … 55 58 if (zpixm) delete zpixm; 56 59 if (lut) delete lut; 60 if (aisup) delete img; // Suppression automatique d'image 57 61 } 58 62 … … 68 72 { 69 73 // SetSize(img->XSize(), img->YSize()); 70 SetPave();74 CenterPave(); 71 75 if (img->minPix>img->maxPix) img->CheckDyn(); 72 76 SetLut(img->minPix, img->maxPix, kLutType_Lin, 1, refr); … … 88 92 } 89 93 90 94 /* --Methode-- */ 95 void PIImage::SetAutoDelImage(bool ad) 96 { 97 aisup = ad; 98 return; 99 } 100 101 /* --Methode-- */ 102 void PIImage::ShowCursor(bool sc) 103 { 104 if (curshow == sc) return; 105 curshow = sc; 106 if (curshow) DrawCursor(); 107 else DrawCursor(-1, -1); 108 return; 109 } 91 110 92 111 /* --Methode-- */ … … 94 113 { 95 114 if (lut) delete(lut); 96 if (lauto )115 if (lauto && img) 97 116 { 98 117 float fracnul, fracsat; 99 118 float fnd, sigfnd; 100 119 float minpix = min; 120 float maxpix = max; 101 121 int npix = img->XSize()*img->YSize(); 102 int vitesse=npix/20000; 103 vitesse = (vitesse < 1) ? 1 : ((vitesse > 10) ? 10 : vitesse ); 104 int nbsig = lauto; 105 float fracmax = 0.95; 106 float minpix = min; 107 float maxpix = max; 108 109 RzFondSig2Ciel(img, vitesse, fracmax, nbsig, 500, &minpix, &maxpix, 122 int rc = -1; 123 if (npix > 2500) // Ca ne marche pas quand il n'y a pas assez de pixels ... 124 { 125 int vitesse=npix/20000; 126 vitesse = (vitesse < 1) ? 1 : ((vitesse > 25) ? 25 : vitesse ); 127 int nbin=npix/10; 128 nbin = (nbin < 1) ? 1 : ((nbin > 500) ? 500 : nbin ); 129 int nbsig = lauto; 130 float fracmax = 0.95; 131 rc = RzFondSig2Ciel(img, vitesse, fracmax, nbsig, nbin, &minpix, &maxpix, 110 132 &fnd, &sigfnd, &min, &max, &fracnul, &fracsat); 133 } 134 if (rc != 0) 135 { 136 img->CheckDyn(minpix, maxpix); 137 min = img->moyPix-3.*img->sigPix; 138 max = img->moyPix+3.*img->sigPix; 139 if (min < minpix) min = minpix; 140 if (max > maxpix) max = maxpix; 141 } 111 142 } 112 143 … … 129 160 } 130 161 162 /* --Methode-- */ 163 void PIImage::SetZoom(float fzm, bool refr) 164 { 165 int zm; 166 167 if (fzm < 0.01) return; 168 if (fzm < 1.) zm = -(1./fzm); 169 else zm = (int)(fzm+0.25); 170 SetZoom(zm, refr); 171 return; 172 } 131 173 132 174 /* --Methode-- */ … … 137 179 else if (zm < -10) zoom = -10; 138 180 else zoom = zm; 139 SetOffset(); 140 if (refr) Apply(); 141 return; 142 } 181 if (img) 182 { SetOffsetFromPave(); 183 if (refr) Apply(); } 184 return; 185 } 186 187 /* --Methode-- */ 188 float PIImage::GetZoom() 189 { 190 if (zoom >= 1) return((float)zoom); 191 else return(-1./(float)zoom); 192 } 193 143 194 144 195 /* --Methode-- */ … … 151 202 if (oy >= (img->YSize()-1)) oy = img->YSize()-2; 152 203 offx = ox; offy = oy; 204 CenterPave(); 153 205 if (refr) Apply(); 154 206 return; 155 207 } 208 209 210 /* --Methode-- */ 211 void PIImage::SetPave(int x, int y, bool refr) 212 { 213 int xc, yc; 214 215 if (img == NULL) 216 { offx = offy = 0; 217 xpav = ypav = 0; 218 return; } 219 220 if ( (x >= (img->XSize()-1)) || ( x < 0) || 221 (y >= (img->YSize()-1)) || ( y < 0) ) return; 222 223 xpav = x; ypav = y; 224 if (PosImg2W(xpav,ypav,&xc, &yc)) // Il faut recenter l'image 225 { SetOffsetFromPave(); 226 if (refr) Apply(true); } 227 else if (refr) 228 { Apply(false); if (curshow) DrawCursor(); } 229 230 return; 231 } 232 156 233 157 234 /* --Methode-- */ … … 167 244 void PIImage::Apply(bool mw) 168 245 { 169 if (mw) ComputePixmap(); 246 if (img == NULL) return; 247 if (mw) 248 { 249 ComputePixmap(); 250 Send(PIMsg_ActiveWdg); 251 } 170 252 if (zow != NULL) 171 253 { … … 180 262 txw->SetLabel((string)buff); 181 263 } 182 Send(PIMsg_ActiveWindow, (char *)this); 264 183 265 return; 184 266 } … … 189 271 // printf("PIImage::Resize\n"); 190 272 PIPixmap::Resize(); 191 SetPave();273 CenterPave(); 192 274 Apply(); 193 275 return; … … 195 277 196 278 /* --Methode-- */ 279 void PIImage::Draw(int x0, int y0, int dx, int dy) 280 { 281 PIPixmap::Draw(x0, y0, dx, dy); 282 winovis = false; // $CHECK$ Reza A enlever si possible 17/6/96 283 if (curshow) 284 { 285 int xc,yc; 286 PosImg2W(xpav, ypav, &xc, &yc); 287 if ((xc >= x0) && (xc < x0+dx) && 288 (yc >= y0) && (yc < y0+dy) ) DrawCursor(xc, yc); 289 } 290 return; 291 } 292 293 /* --Methode-- */ 197 294 void PIImage::But1Press(int x, int y) 198 295 { 199 296 int xp, yp; 200 297 298 Send(PIMsg_ActiveWdg); 201 299 if (img == NULL) return; 202 300 if ( PosW2Img(x, y, &xp, &yp) ) return; … … 204 302 xpav = xp; ypav = yp; 205 303 Apply(false); 304 if (curshow) DrawCursor(-1,-1); 206 305 return; 207 306 } … … 224 323 { 225 324 SelPointerShape(PI_ArrowPointer); 325 if (curshow) DrawCursor(); 226 326 return; 227 327 } … … 233 333 int xp, yp; 234 334 335 Send(PIMsg_ActiveWdg); 235 336 if (img == NULL) return; 236 337 if ( PosW2Img(x, y, &xp, &yp) ) { xmv0 = -1; return; } 237 338 xmv0 = x; ymv0 = y; dxmv = dymv = 0; 238 Send(PIMsg_ActiveWindow, (char *)this);339 if (curshow) DrawCursor(-1,-1); 239 340 SelGOMode(PI_GOXOR); 341 if (GetColMapId() == CMAP_COLRJ32) 240 342 SelForeground(PI_Yellow); 241 SelLine(PI_ThinLine); 343 else SelForeground(PI_Magenta); 344 SelLine(PI_NormalLine); 242 345 return; 243 346 } … … 261 364 int xp, yp, xp2, yp2; 262 365 263 if (img == NULL) return;264 366 if (img == NULL) return; 265 367 if (xmv0 < 0) return; … … 276 378 277 379 Apply(false); 380 if (curshow) DrawCursor(); 278 381 return; 279 382 } … … 285 388 int xp, yp; 286 389 390 Send(PIMsg_ActiveWdg); 287 391 if (img == NULL) return; 288 392 if ( PosW2Img(x, y, &xp, &yp) ) { xmv0 = -1; return; } 393 if (curshow) DrawCursor(-1,-1); 289 394 SelPointerShape(PI_TDLRArrowPointer); 290 395 xmv0 = xp; 291 396 ymv0 = yp; 292 Send(PIMsg_ActiveWindow, (char *)this);293 397 return; 294 398 } … … 476 580 } 477 581 582 /* --Methode-- */ 583 void PIImage::DrawCursor() 584 { 585 int xc, yc; 586 if (PosImg2W(xpav, ypav, &xc, &yc)) DrawCursor(-1, -1); 587 else DrawCursor(xc, yc); 588 return; 589 } 590 591 #define CURSHSIZE 25 592 593 /* --Methode-- */ 594 void PIImage::DrawCursor(int xc, int yc) 595 { 596 597 if ((xcurs>=0) && (ycurs>=0)) 598 PIPixmap::Draw(xcurs-CURSHSIZE, ycurs-CURSHSIZE, CURSHSIZE*2, CURSHSIZE*2); 599 600 if ((xc >= 0) && (yc >= 0)) 601 { 602 xcurs = xc; ycurs = yc; 603 if (winovis) return; // $CHECK$ Reza A enlever si possible 17/6/96 604 if (zoom < 3) SelLine(PI_NormalLine); 605 else SelLine(PI_ThickLine); 606 SelGOMode(PI_GOCopy); 607 DrawLine(xcurs-CURSHSIZE, ycurs, xcurs-4, ycurs); 608 DrawLine(xcurs+4, ycurs, xcurs+CURSHSIZE, ycurs); 609 DrawLine(xcurs, ycurs-CURSHSIZE, xcurs, ycurs-4); 610 DrawLine(xcurs, ycurs+4, xcurs, ycurs+CURSHSIZE); 611 } 612 else { xcurs = ycurs = -1; } 613 614 return; 615 } 478 616 479 617 /* --Methode-- */ … … 498 636 499 637 500 501 /* --Methode-- */ 502 void PIImage::SetOffset() 638 /* --Methode-- */ 639 int PIImage::PosImg2W(int xp, int yp, int * xiw, int * yiw) 640 { 641 if (zoom > 0) 642 { 643 *xiw = (xp-offx)*zoom+(zoom/2); 644 *yiw = (yp-offy)*zoom+(zoom/2); 645 } 646 else 647 { 648 *xiw = (offx-xp)/zoom; 649 *yiw = (offy-yp)/zoom; 650 } 651 652 if (*xiw > XSize()) *xiw = -1; 653 if (*yiw > YSize()) *yiw = -1; 654 655 if ((*xiw < 0) || (*yiw < 0)) return(1); 656 else return(0); 657 } 658 659 660 /* --Methode-- */ 661 void PIImage::SetOffsetFromPave() 503 662 { 504 663 if (zoom > 0) … … 522 681 523 682 /* --Methode-- */ 524 void PIImage:: SetPave()683 void PIImage::CenterPave() 525 684 { 526 685 int xwsz, ywsz; 527 686 528 xwsz = XSize(); ywsz = YSize(); 687 if (zoom > 0) 688 { xwsz = XSize()/zoom; 689 ywsz = YSize()/zoom; } 690 else 691 { xwsz = -(XSize()*zoom); 692 ywsz = -(YSize()*zoom); } 693 529 694 if (xwsz > (img->XSize()-offx)) xwsz = (img->XSize()-offx); 530 695 if (ywsz > (img->YSize()-offy)) ywsz = (img->YSize()-offy); -
trunk/SophyaPI/PI/piimage.h
r11 r18 25 25 26 26 void SetImage(RzImage *pim, bool refr=true); 27 void SetAutoDelImage(bool ad = false); 28 27 29 void SetZoomWin(PIPixmap * zw, bool refr=true); 28 30 inline void SetTextWin(PILabel * tw) { txw = tw; }; 31 void ShowCursor(bool sc=true); 29 32 30 33 void SetLut(float min, float max, int typlut=kLutType_Lin, … … 33 36 34 37 void SetZoom(int zm, bool refr=true); 38 void SetZoom(float fzm, bool refr=true); 39 float GetZoom(); 40 35 41 void SetOffset(int ox, int oy, bool refr=true); 42 void SetPave(int x, int y, bool refr=true); 36 43 37 44 virtual void SetColMap(CMapId cmap, bool refr=true); … … 48 55 49 56 virtual void Resize(); 57 virtual void Draw(int x0, int y0, int dx, int dy); 50 58 51 59 virtual void But1Press(int x, int y); … … 67 75 void ComputeZoomPixmap(); 68 76 77 void DrawCursor(); 78 void DrawCursor(int xc, int yc); 79 69 80 int PosW2Img(int xiw, int yiw, int * xp, int * yp); 70 void SetOffset(); 71 void SetPave(); 72 void SetPave(int x, int y, int dx=-1, int dy = -1); 81 int PosImg2W(int xp, int yp, int * xiw, int * yiw); 82 83 void SetOffsetFromPave(); 84 void CenterPave(); 73 85 74 86 // Les donnees 75 87 76 88 RzImage * img; 89 bool aisup; 90 bool curshow; 91 bool winovis; // $CHECK$ Reza A enlever si possible 17/6/96 77 92 78 93 unsigned char * pixm; … … 91 106 int xmv0, ymv0; 92 107 int dxmv, dymv; 108 int xcurs, ycurs; 93 109 int xszpav, yszpav; 94 110 -
trunk/SophyaPI/PI/pimak
r16 r18 76 76 77 77 #------------------------------------------------- End of Makefile.h ------- 78 all : piapp 78 all : piapp piapp_nosh 79 79 80 piapp : $(EXE)piapp $(SLB)piup.so user.so 80 piapp : $(EXE)piapp $(SLB)piup.so 81 82 piapp_nosh : $(EXE)piapp_nosh 81 83 82 84 … … 86 88 -L$(SLB) -lPI -lOuIm -lerosc -lStarReco \ 87 89 -lgcxx -lXm -lXt -lX11 -lm 90 91 $(EXE)piapp_nosh : $(OBJ)pidemo_nosh.o $(LIB)libPI.a $(LIB)libStarReco.a \ 92 $(LIB)libOutils.a $(LIB)libImages.a $(LIB)libmath.a $(LIB)libdiv.a 93 g++ -o $(EXE)piapp_nosh $(OBJ)pidemo_nosh.o \ 94 -L$(LIB) -lPI -lStarReco -lImages -lOutils -lmath -ldiv \ 95 -lXm -lXt -lX11 -lm 96 88 97 $(SLB)piup.so : $(OBJ)piup_def.o \ 89 98 $(SLB)libOuIm.so $(SLB)liberosc.so … … 91 100 -none -L$(SLB) -lOuIm -lerosc -lgcxx -lm -lc 92 101 93 user.so : $(OBJ)piup.o \ 94 $(SLB)libOuIm.so $(SLB)liberosc.so 95 ld -shared -o user.so -all $(OBJ)piup.o \ 96 -none -L$(SLB) -lOuIm -lerosc -lgcxx -lm -lc 97 102 $(OBJ)pidemo_nosh.o: pidemo.cc pidemo.h 103 g++ -g -O -c -Wall -Wpointer-arith \ 104 -Wmissing-prototypes -Wsynth -I$(INC) -I$(CXI) \ 105 -D C_NO_SHLIBS -o $(OBJ)pidemo_nosh.o pidemo.cc 98 106 99 107 $(OBJ)pidemo.o: ./pidemo.cc \ … … 120 128 $(INC)utils.h pidrawwin.h \ 121 129 $(INC)piup.h 122 $(OBJ)piup.o: piup.cc piup.h \123 $(INC)perrors.h \124 $(INC)exceptions.h \125 $(INC)defs.h \126 $(INC)fitsimage.h \127 $(INC)cimage.h \128 $(INC)rzimage.h \129 $(INC)rzvect.h \130 $(INC)machine.h \131 $(INC)datatypes.h \132 $(INC)fitsheader.h \133 $(INC)fitskeys.h \134 $(INC)utils.h $(INC)peida.h135 130 $(OBJ)piup_def.o: piup_def.cc piup.h \ 136 131 $(INC)perrors.h \ -
trunk/SophyaPI/PI/pimsghandler.cc
r2 r18 18 18 PIMsgHandler::Send(long msg, void* data) 19 19 { 20 Process(msg, this, data); 20 // Process(msg, this, data); $CHECK$ Reza 12/06/96 21 // Send par defaut appelle le process du parent $CHECK$ 22 if (msgParent) 23 msgParent->Process(msg, this, data); 24 21 25 } 22 26 -
trunk/SophyaPI/PI/pimsghandler.h
r8 r18 8 8 enum { 9 9 // Les messages 10 PIMsg_ActiveW indow= 1,10 PIMsg_ActiveWdg = 1, 11 11 PIMsg_OK = 2, 12 12 PIMsg_Cancel = 3, -
trunk/SophyaPI/PI/piperiodx.cc
r15 r18 1 1 #include "piperiodx.h" 2 #include <algo.h>3 #include <signal.h>4 2 5 PIPeriodX::PIPeriodX(int d) 6 : PIPeriodGen(d), it(-1) 7 {} 3 /* Nouvelle-Fonction */ 4 static void xttimer_action(XtPointer usd, XtIntervalId * /*tid*/) 5 { 6 PIPeriodX * pip; 7 XtIntervalId id; 8 pip = (PIPeriodX *)usd; 9 pip->DoPeriodic(); 10 id = XtAddTimeOut(pip->Interval()*1000, xttimer_action, pip); 11 pip->SetTimerId(id); 12 return; 13 } 8 14 15 16 /* --Methode-- */ 17 PIPeriodX::PIPeriodX(int dt, UsPeriodicAction act, void * usp) 18 : Periodic(dt, act, usp) 19 { 20 } 21 22 /* --Methode-- */ 9 23 PIPeriodX::~PIPeriodX() 10 {} 24 { 25 if (mFgact) Stop(); 26 } 11 27 12 void 13 PIPeriodX::Start()28 /* --Methode-- */ 29 void PIPeriodX::Start(int dt) 14 30 { 15 if (it < 0) { 16 if (!actifs) actifs = new PIPeriodList; 17 it = 0; 18 if (actifs->size() == 0) { 19 signal(SIGALRM, CallBack); 20 alarm(1); 21 } 22 actifs->push_back(this); 23 } 31 if (mFgact) return; 32 if (dt > 0) mDt = dt; 33 34 mTId = XtAddTimeOut(mDt*1000, xttimer_action, this); 35 mFgact = true; 36 return; 24 37 } 25 38 … … 27 40 PIPeriodX::Stop() 28 41 { 29 if (it >= 0) { 30 it = -1; 31 remove(actifs->begin(), actifs->end(), this); 32 if (actifs->size() == 0) { 33 signal(SIGALRM, NULL); 34 delete actifs; 35 actifs = NULL; 36 } 37 } 42 if(mFgact) 43 XtRemoveTimeOut(mTId); 44 mFgact = false; 45 return; 38 46 } 39 47 40 PIPeriodList* PIPeriodX::actifs = NULL;41 42 void PIPeriodX::CallBack(int)43 {44 if (!actifs) return;45 46 for (PIPeriodList::iterator i = actifs->begin(); i != actifs->end(); i++) {47 PIPeriodX* p = (PIPeriodX*) *i;48 p->it ++;49 if (p->it >= p->dt) {50 p->it = 0;51 p->DoPeriodic();52 }53 }54 alarm(1);55 }56 -
trunk/SophyaPI/PI/piperiodx.h
r15 r18 3 3 #define PIPERIODX_H 4 4 5 #include "piperiodgen.h" 5 #include <X11/Intrinsic.h> 6 #include "periodic.h" 6 7 7 class PIPeriodX : public P IPeriodGen{8 class PIPeriodX : public Periodic { 8 9 public: 9 PIPeriodX(int dt );10 PIPeriodX(int dt, UsPeriodicAction act=NULL, void * usp=NULL); 10 11 ~PIPeriodX(); 11 12 12 v oid Start();13 v oid Stop();13 virtual void Start(int dt=-1); 14 virtual void Stop(); 14 15 15 static PIPeriodList* actifs; 16 static void CallBack(int); 16 inline void SetTimerId(XtIntervalId id) {mTId=id; } 17 17 18 18 protected: 19 int it;19 XtIntervalId mTId; 20 20 }; 21 21 -
trunk/SophyaPI/PI/pipixmapx.cc
r9 r18 32 32 unsigned char *pp; 33 33 34 for(j=0; j<ny; j++)34 if (pixmap) 35 35 { 36 pp = pixmap+j*nx; 37 for(i=0; i<nx; i++) 38 { XPutPixel(myximg, i, j, cmap->Color(*pp) ); pp++; } 36 for(j=0; j<ny; j++) 37 { 38 pp = pixmap+j*nx; 39 for(i=0; i<nx; i++) 40 { XPutPixel(myximg, i, j, cmap->Color(*pp) ); pp++; } 41 } 42 43 for(j=ny; j<YSize(); j++) 44 for(i=nx; i<XSize(); i++) 45 XPutPixel(myximg, i, j, 0 ); 39 46 } 40 41 for(j=ny; j<YSize(); j++)42 for(i=nx; i<XSize(); i++)43 XPutPixel(myximg, i, j, 0 );44 45 47 PIBaseWdgX::Refresh(); 46 48 } … … 86 88 87 89 XPutImage(mdsp, xw, mygc, myximg, x0, y0, x0, y0, dx, dy); 88 X Sync(mdsp, 0);90 XFlush(mdsp); 89 91 90 92 return; … … 129 131 int depth; 130 132 int pad; 133 int i,j; 131 134 132 135 xw = XtWindow(XtWdg()); … … 140 143 if (myximg == NULL) return; 141 144 myximg->data = new char [YSize()*myximg->bytes_per_line]; 142 if (myximg->data == NULL) XFree(myximg); 145 if (myximg->data == NULL) 146 { XFree(myximg); myximg = NULL; } 147 148 for(j=0; j<YSize(); j++) 149 for(i=0; i<XSize(); i++) 150 XPutPixel(myximg, i, j, 0 ); 151 143 152 return; 144 153 } -
trunk/SophyaPI/PI/piscdrawwdg.cc
r15 r18 2 2 #include "generalfit.h" 3 3 #include <algo.h> 4 4 5 5 6 PIScDrawWdg::PIScDrawWdg(PIContainerGen *par, char *nom, … … 12 13 SetAxesFlags(kAxesDflt); 13 14 clip = true; 15 padsup = false; 16 mTxw = NULL; 17 ActivateButton(1); // Pour pouvoir activer la fenetre et coordonnees 18 ActivateMove(1); // " " " " 14 19 ActivateButton(2); 15 20 ActivateMove(2); … … 488 493 PIScDrawWdg::RemoveDrawer(PIScDrawer* d) 489 494 { 495 if (padsup) return; 490 496 mDrawers.remove(d); 491 497 d->mDrawWdg = NULL; … … 495 501 PIScDrawWdg::DeleteDrawers() 496 502 { 503 padsup = true; 497 504 for(list<PIScDrawer*>::iterator i = mDrawers.begin(); i != mDrawers.end(); i++) 498 505 delete *i; 499 500 506 mDrawers.erase(mDrawers.begin(),mDrawers.end()); 507 padsup = false; 501 508 } 502 509 … … 535 542 536 543 544 545 // Gestion affichage coordonnees du point 546 void 547 PIScDrawWdg::But1Press(int x, int y) 548 { 549 if (UpdateText(x, y)) 550 SelPointerShape(PI_CrossPointer); 551 Send(PIMsg_ActiveWdg); 552 553 } 554 555 void 556 PIScDrawWdg::Ptr1Move(int x, int y) 557 { 558 UpdateText(x, y); 559 } 560 561 void 562 PIScDrawWdg::But1Release(int x, int y) 563 { 564 if (UpdateText(x, y)) 565 SelPointerShape(PI_ArrowPointer); 566 567 } 568 569 bool 570 PIScDrawWdg::UpdateText(int xp, int yp) 571 { 572 if (mTxw == NULL) return(false); 573 574 char buff[128]; 575 double dx, dy; 576 Local2Sc(xp, yp, dx, dy); 577 sprintf(buff, "X= %g Y= %g", dx, dy); 578 mTxw->SetLabel((string)buff); 579 return(true); 580 581 } 582 537 583 // Gestion du zoom 538 539 584 void 540 585 PIScDrawWdg::But2Press(int x, int y) … … 550 595 SelGOMode(PI_GOXOR); 551 596 SelLine(PI_ThinLine); 597 Send(PIMsg_ActiveWdg); 552 598 } 553 599 -
trunk/SophyaPI/PI/piscdrawwdg.h
r15 r18 5 5 #include "pisysdep.h" 6 6 #include PIBWDG_H 7 #include PISTDWDG_H 7 8 8 9 #include <list.h> … … 67 68 virtual void SetAxesFlags(int flags=kAxesDflt); 68 69 70 void SetTextWin(PILabel * tw) {mTxw = tw; } 71 69 72 double XMin() const {return xMin;} 70 73 double XMax() const {return xMax;} … … 75 78 void NoClip() {clip = false;} 76 79 void Clip() {clip = true;} 77 78 80 81 82 virtual void But1Press(int x, int y); 83 virtual void But1Release(int x, int y); 84 virtual void Ptr1Move(int x, int y); 85 79 86 virtual void But2Press(int x, int y); 80 87 virtual void But2Release(int x, int y); … … 103 110 PIPointer cPointer; 104 111 PILineAtt cLatt; 112 PILabel * mTxw; 105 113 bool clip; 106 114 bool padsup; 115 116 107 117 private: 108 118 void DrawHTicks(double y, double tickUp, double tickDown, double xBeg, double xStep); … … 110 120 void DrawHLabels(double y, double xBeg, double xStep, int just=0); 111 121 void DrawVLabels(double x, double yBeg, double yStep, int just=0); 122 123 bool UpdateText(int xp, int yp); 112 124 }; 113 125 -
trunk/SophyaPI/PI/pisysdep.h
r15 r18 40 40 #define PIPIXMAP_H "pipixmapx.h" 41 41 42 #define PIPERIODIC_H "piperiodicx.h" 43 42 44 #endif 43 45 -
trunk/SophyaPI/PI/pitestapp.cc
r15 r18 207 207 this->label->SetLabel(truc); 208 208 209 if (msg == PIMsg_ActiveW indow)209 if (msg == PIMsg_ActiveWdg) 210 210 { /* printf("Process: Setting active ImageWindow (%lx) \n", (long)data); */ 211 211 cur = (PIImage *)data; } -
trunk/SophyaPI/PI/piup.cc
r13 r18 8 8 #include "piup.h" 9 9 10 FitsImageR4 * PIUserProc_1(FitsImageR4 * myimg, int xp, int yp, int dx, int dy,11 10 ImageR4 * PIUserProc_1(ImageR4 * myimg, int xp, int yp, int dx, int dy, 11 char * arg1, char * arg2) 12 12 { 13 13 printf("**** PIUserProc_1 Pave[%d*%d] en (%d,%d) %s %s Filtrage passe-bas 3*3 \n", 14 14 dx, dy, xp, yp, arg1, arg2); 15 15 ImageR4 filt(3,3); 16 FitsImageR4 * out;16 ImageR4 * out; 17 17 18 18 // Definition du filtre passe-bas … … 23 23 24 24 filt.PrintImage(); 25 out = new FitsImageR4(myimg->XSize(), myimg->YSize());25 out = new ImageR4(myimg->XSize(), myimg->YSize()); 26 26 TIMEF ; 27 27 FilterImage((ImageR4 *) myimg, (ImageR4 *)out, &filt); … … 29 29 } 30 30 31 FitsImageR4 * PIUserProc_2(FitsImageR4 * myimg, int xp, int yp, int dx, int dy,32 31 ImageR4 * PIUserProc_2(ImageR4 * myimg, int xp, int yp, int dx, int dy, 32 char * arg1, char * arg2) 33 33 { 34 34 printf("**** PIUserProc_2 Pave[%d*%d] en (%d,%d) %s %s Ombre 3*3 \n", … … 36 36 printf(" PIUserProc_2(%d %d %s %s) Ombre 3*3 \n", xp, yp, arg1, arg2); 37 37 ImageR4 filt(3,3); 38 FitsImageR4 * out;38 ImageR4 * out; 39 39 40 40 // Definition du filtre ombre … … 46 46 filt(2,0) = 2.; 47 47 filt.PrintImage(); 48 out = new FitsImageR4(myimg->XSize(), myimg->YSize());48 out = new ImageR4(myimg->XSize(), myimg->YSize()); 49 49 TIMEF ; 50 50 FilterImage((ImageR4 *) myimg, (ImageR4 *)out, &filt); … … 53 53 54 54 55 FitsImageR4 * PIUserProc_3(FitsImageR4 * , int xp, int yp, int dx, int dy,56 55 ImageR4 * PIUserProc_3(ImageR4 * , int xp, int yp, int dx, int dy, 56 char * arg1, char * arg2) 57 57 { 58 58 printf("PIUserProc_3 Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", -
trunk/SophyaPI/PI/piup.h
r11 r18 1 #include " fitsimage.h"1 #include "cimage.h" 2 2 3 FitsImageR4 * PIUserProc_1(FitsImageR4 * myimg, int xp, int yp, int dx, int dy,4 5 FitsImageR4 * PIUserProc_2(FitsImageR4 * myimg, int xp, int yp, int dx, int dy,6 7 FitsImageR4 * PIUserProc_3(FitsImageR4 * myimg, int xp, int yp, int dx, int dy,8 3 ImageR4 * PIUserProc_1(ImageR4 * myimg, int xp, int yp, int dx, int dy, 4 char * arg1, char * arg2); 5 ImageR4 * PIUserProc_2(ImageR4 * myimg, int xp, int yp, int dx, int dy, 6 char * arg1, char * arg2); 7 ImageR4 * PIUserProc_3(ImageR4 * myimg, int xp, int yp, int dx, int dy, 8 char * arg1, char * arg2); -
trunk/SophyaPI/PI/piup_def.cc
r11 r18 8 8 #include "piup.h" 9 9 10 FitsImageR4 * PIUserProc_1(FitsImageR4 * , int xp, int yp, int dx, int dy,11 10 ImageR4 * PIUserProc_1(ImageR4 * , int xp, int yp, int dx, int dy, 11 char * arg1, char * arg2) 12 12 { 13 13 printf("PIUserProc_1/Dummy Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", … … 16 16 } 17 17 18 FitsImageR4 * PIUserProc_2(FitsImageR4 * , int xp, int yp, int dx, int dy,19 18 ImageR4 * PIUserProc_2(ImageR4 * , int xp, int yp, int dx, int dy, 19 char * arg1, char * arg2) 20 20 { 21 21 printf("PIUserProc_2/Dummy Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", … … 24 24 } 25 25 26 FitsImageR4 * PIUserProc_3(FitsImageR4 * , int xp, int yp, int dx, int dy,27 26 ImageR4 * PIUserProc_3(ImageR4 * , int xp, int yp, int dx, int dy, 27 char * arg1, char * arg2) 28 28 { 29 29 printf("PIUserProc_3/Dummy Pave[%d,%d] en (%d %d) %s %s ne fait rien !\n", -
trunk/SophyaPI/PI/piwdggen.cc
r2 r18 12 12 parent = par; 13 13 SetMsg(0); 14 if (par) par-> NewChild(this);14 if (par) par->ChildAdd(this); // On previent le container parent 15 15 return; 16 16 } … … 20 20 PIWdgGen::~PIWdgGen() 21 21 { 22 if (parent) parent->ChildDel(this); // On previent le container parent 22 23 } 23 24 -
trunk/SophyaPI/PI/piwindowgen.cc
r2 r18 1 1 #include "piwindowgen.h" 2 2 3 4 /* --Methode-- */ 3 5 PIWindowGen::PIWindowGen(PIMsgHandler *par, char *nom, PIWindowKind k, 4 6 int sx, int sy, int px, int py) … … 9 11 10 12 13 /* --Methode-- */ 11 14 PIWindowGen::~PIWindowGen() 12 15 {} 13 16 14 17 15 18 /* --Methode-- */ 19 void PIWindowGen::Process(long msg, PIMsgHandler* sender, void* data) 20 /* On intercepte le message ActiveWdg, avant de le renvoyer, */ 21 /* avec un message ActiveWdg de la part de la fenetre */ 22 { 23 if (msg == PIMsg_ActiveWdg) 24 Send(msg); 25 ReSend(msg, sender, data); 26 return; 27 } -
trunk/SophyaPI/PI/piwindowgen.h
r2 r18 20 20 21 21 virtual long kind() {return ClassId; } 22 23 virtual void Process(long msg, PIMsgHandler* sender, void* data=NULL); 22 24 23 protected: 25 protected: 24 26 PIWindowKind mWtyp; 25 27 };
Note:
See TracChangeset
for help on using the changeset viewer.