[165] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | // Standard Image App R. Ansari 97-98
|
---|
| 3 | // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
|
---|
| 4 |
|
---|
| 5 | #ifndef PISTIMGAPP_H_SEEN
|
---|
| 6 | #define PISTIMGAPP_H_SEEN
|
---|
| 7 |
|
---|
| 8 | #include <string.h>
|
---|
| 9 | #include <string>
|
---|
| 10 | #include <map>
|
---|
[351] | 11 | #include <functional>
|
---|
[165] | 12 |
|
---|
| 13 | #include "pisysdep.h"
|
---|
| 14 |
|
---|
| 15 | #include PIAPP_H
|
---|
| 16 | #include PIWIN_H
|
---|
| 17 | #include PIMENU_H
|
---|
| 18 | #include PIOPTMENU_H
|
---|
| 19 |
|
---|
| 20 | #include PISTDWDG_H
|
---|
| 21 |
|
---|
| 22 | #include PIFILECHO_H
|
---|
[2106] | 23 | #include PIPERIODIC_H
|
---|
| 24 |
|
---|
[165] | 25 | #include "picons.h"
|
---|
| 26 |
|
---|
| 27 | #include "piimage.h"
|
---|
[2141] | 28 | #include "pi3dwdg.h"
|
---|
[165] | 29 | #include "nobjmgr.h"
|
---|
| 30 | #include "piacmd.h"
|
---|
| 31 | #include "pisiadw.h"
|
---|
| 32 | #include "pistzwin.h"
|
---|
| 33 |
|
---|
[2106] | 34 | #include "pitherm.h"
|
---|
[165] | 35 |
|
---|
[2486] | 36 | #include "zthread.h"
|
---|
[2106] | 37 | #include "resusage.h"
|
---|
| 38 |
|
---|
| 39 |
|
---|
[1971] | 40 | enum DispWinEnum {Disp_Default, Disp_Next, Disp_Win, Disp_Same, Disp_Stack, Disp_Inset};
|
---|
[165] | 41 |
|
---|
| 42 | typedef map<long, PIWindow*, less<long> > WindMList;
|
---|
| 43 | typedef map<long, PIBaseWdg*, less<long> > BWMList;
|
---|
| 44 | typedef map<long, PIDrawer*, less<long> > DrwMList;
|
---|
| 45 |
|
---|
| 46 | class PIStdImgApp : public PIApplication {
|
---|
| 47 | public:
|
---|
| 48 | PIStdImgApp(int narg=0, char* arg[]=NULL);
|
---|
| 49 | ~PIStdImgApp();
|
---|
| 50 |
|
---|
| 51 | virtual void Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
[194] | 52 | virtual void SetReady();
|
---|
| 53 | virtual void SetBusy();
|
---|
| 54 | virtual void SetBlocked();
|
---|
[165] | 55 |
|
---|
[2486] | 56 | // <ZThread> Multithread execution
|
---|
| 57 | // On redefinit la methode Run pour gestion multithread
|
---|
| 58 | virtual void Run();
|
---|
| 59 | inline ZMutex & getMutex() { return thr_glsyn; }
|
---|
[2492] | 60 | inline void LockMutex() { thr_glsyn.lock(); }
|
---|
| 61 | inline void UnlockMutex(bool fgbr=false)
|
---|
[2494] | 62 | { if (fgbr) thr_glsyn.broadcast(); thr_glsyn.unlock(); }
|
---|
[2490] | 63 | inline bool isGlSyncLocked() { return fg_glsynlock; }
|
---|
[2494] | 64 | int CheckPendingEvents();
|
---|
[2486] | 65 |
|
---|
| 66 | // Methodes d'Affichage generique
|
---|
[2491] | 67 | int DispImage(P2DArrayAdapter* nouv, string const & name, string const & opt,
|
---|
| 68 | int oid=0, bool fglock=true);
|
---|
[1971] | 69 | int DispScDrawer(PIDrawer* scd, string const & name, string const & opt,
|
---|
[2491] | 70 | string title="", int oid=0, bool fglock=true);
|
---|
[1971] | 71 | int Disp3DDrawer(PIDrawer3D* scd, string const & name, string const & opt,
|
---|
[2491] | 72 | string title="", int oid=0, bool fglock=true);
|
---|
[165] | 73 |
|
---|
[2188] | 74 | // Specification (de l'exterieur) de commande a executer
|
---|
| 75 | inline void SubmitCommand(string const& cmd)
|
---|
| 76 | { exc_command = cmd; fg_exc_cmd = true; }
|
---|
| 77 | // Execution de commande soumis de l'exterieur
|
---|
| 78 | int ExecuteExtCommand();
|
---|
| 79 |
|
---|
[1642] | 80 | // Fonction d'ajout de texte (provisoire - Aout 99)
|
---|
[2263] | 81 | void AddText(string const & txt, double xp, double yp, string const& opt, bool fgcn=false);
|
---|
| 82 | void AddCompText(string const & txt, string const & txtup, string const & txtdn,
|
---|
| 83 | double xp, double yp, string const& opt,
|
---|
| 84 | string const& optss, bool fgcn=false);
|
---|
[1642] | 85 | // Ajout de lignes, rectangles, cercles (provisoires - Aout 2001)
|
---|
[2243] | 86 | void AddLine(double xp1, double yp1, double xp2, double yp2,
|
---|
[2263] | 87 | string const& opt, bool fgarrow=false, bool fgcn=false);
|
---|
[1971] | 88 | void AddRectangle(double xp1, double yp1, double xp2, double yp2, string const& opt,
|
---|
[2263] | 89 | bool fgfill=false, bool fgcn=false);
|
---|
[1971] | 90 | void AddCircle(double xc, double yc, double r, string const& opt,
|
---|
[2263] | 91 | bool fgfill=false, bool fgcn=false);
|
---|
[2265] | 92 | void AddArc(double xc, double yc, double r, double a, double da,
|
---|
| 93 | string const& opt, bool fgfill=false, bool fgcn=false);
|
---|
[2243] | 94 | void AddArc(double x1, double y1, double x2, double y2,
|
---|
[2263] | 95 | double x3, double y3, string const& opt, bool fgfill=false, bool fgcn=false);
|
---|
| 96 | void AddPoly(vector<double>& x, vector<double>& y,
|
---|
| 97 | string const& opt, bool fgfill=false, bool fgcn=false);
|
---|
[1642] | 98 |
|
---|
[1131] | 99 | // Fonction Ajout de titre de trace
|
---|
[2165] | 100 | void SetTitle(string const & titleup, string const & titledown, string const& opt);
|
---|
| 101 | // Fonction d'Ajout label d'axe X,Y
|
---|
| 102 | void SetAxeLabels(string const & xLabel, string const & yLabel, string const& opt);
|
---|
[349] | 103 |
|
---|
[1642] | 104 | // Acces au BaseDrawer (PIElDrawer) du PIBaseWdg courant
|
---|
[2165] | 105 | PIDrawer* CurrentElDrawer();
|
---|
[349] | 106 |
|
---|
[165] | 107 | void CreateGraphWin(int nx=1, int ny=1, int sx=0, int sy = 0);
|
---|
| 108 | void CreateStackWin(int sx=0, int sy = 0);
|
---|
[1971] | 109 | PIWindow * GetWindow(DispWinEnum typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom);
|
---|
[165] | 110 | void SetZone(int nzx=1, int nzy=1);
|
---|
| 111 | void StackWinNext();
|
---|
| 112 |
|
---|
| 113 | void DeleteWindow(PIWindow* w);
|
---|
| 114 | void DeleteBaseWidget(PIBaseWdg* w, bool dw=true, bool dwin=true);
|
---|
| 115 | void DelWRsId(int k);
|
---|
[368] | 116 | bool CheckWRsId(int k);
|
---|
[165] | 117 | void CloseAllWindows();
|
---|
| 118 |
|
---|
| 119 | inline NamedObjMgr* ObjMgr() { return mObjMgr; }
|
---|
| 120 | inline PIACmd* CmdInterpreter() { return mCmd; }
|
---|
| 121 |
|
---|
| 122 | PIWindow* CurrentWindow() { return (mCurWin); };
|
---|
| 123 | PIBaseWdg* CurrentBaseWdg() { return (mCurWdg); };
|
---|
| 124 |
|
---|
| 125 | inline PIPixmap* ZoomW() { return zoom; }
|
---|
| 126 | inline PIPixmap* GloVW() { return gimv; }
|
---|
| 127 | inline PICMapView* CMapVW() { return cmapv; }
|
---|
| 128 | inline PIConsole* GetConsole() { return mCons; }
|
---|
| 129 |
|
---|
[293] | 130 | inline PIMenu* SpecialMenu() { return m[5]; }
|
---|
| 131 | inline PIMenu* ModulesMenu() { return m[6]; }
|
---|
[165] | 132 |
|
---|
| 133 | inline ObjMgrWind* ObjMgrW() { return mObjmgrw; }
|
---|
| 134 | inline PPInMgrWind* PPInMgrW() { return mPpinmgrw; }
|
---|
| 135 |
|
---|
[1971] | 136 | // Gestion (show/hide) de la fenetre Stat/ZoomWindow
|
---|
| 137 | void StatZoomWindowSetVisible(bool fg=true);
|
---|
| 138 |
|
---|
[2106] | 139 | // Update de l'info de la fenetre stats/ressources
|
---|
| 140 | void UpdateStatResourceInfo();
|
---|
| 141 |
|
---|
[165] | 142 | // Redirection ou Non de StdOut/StdErr
|
---|
| 143 | void RedirectStdOutErr(bool fg = true);
|
---|
[293] | 144 | inline bool HasRedirectedStdOutErr() { return(redirecout); }
|
---|
[165] | 145 | // Gestion des signaux
|
---|
[374] | 146 | void CatchSignals(bool fgfpe=true, bool fgsegv=true);
|
---|
[165] | 147 |
|
---|
[548] | 148 | void SetInsetLimits(double xmin=0.4, double xmax=0.6, double ymin=0.4, double ymax=0.6);
|
---|
[1131] | 149 | inline void SetAutoAddTitle(bool aatit=true) { mAddTitle = aatit; }
|
---|
[1971] | 150 | void SetAxesAtt(unsigned int axfl) { mAxesFlags = axfl; }
|
---|
| 151 | // void SaveGraphicAtt();
|
---|
| 152 | // void RestoreGraphicAtt();
|
---|
| 153 | void SetDefaultGraphicAttributes(string const & opt);
|
---|
| 154 | void SetDefaultAxesAttributes(string const & opt);
|
---|
| 155 | DispWinEnum ParseDisplayOption(string const & opt, vector<string>& opts);
|
---|
[506] | 156 |
|
---|
[165] | 157 | // Gestion fichiers PS
|
---|
| 158 | int num_eps;
|
---|
| 159 | PSFile *mpsfile;
|
---|
| 160 | string name_ps;
|
---|
| 161 |
|
---|
| 162 | // Gestion OUT-PPF
|
---|
| 163 | POutPersist* mPpfout;
|
---|
| 164 | string name_outppf;
|
---|
| 165 |
|
---|
| 166 | private:
|
---|
| 167 | void MBProcess1(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
| 168 | void MBProcess2(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
| 169 | void MBProcess3(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
| 170 | void MBProcess4(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
| 171 | void MBProcess5(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
| 172 | void MBProcess6(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
| 173 |
|
---|
[1971] | 174 |
|
---|
[165] | 175 |
|
---|
| 176 | NamedObjMgr* mObjMgr;
|
---|
| 177 | PIACmd* mCmd;
|
---|
| 178 |
|
---|
[293] | 179 | PIMenu* m[7];
|
---|
[165] | 180 | PIMenu* mc;
|
---|
| 181 |
|
---|
[1971] | 182 | PIContainer* statcont; // Container pour les widgets zoom, gimv, cmapv ...
|
---|
[165] | 183 | PIPixmap* zoom;
|
---|
| 184 | PIPixmap* gimv;
|
---|
| 185 | PICMapView* cmapv;
|
---|
[2486] | 186 | // Pour afficher des stats et etat thread command
|
---|
[2106] | 187 | PILabel* lab_mem;
|
---|
| 188 | PIThermometer* therm_mem;
|
---|
| 189 | PILabel* lab_cpu;
|
---|
| 190 | PIThermometer* therm_cpu;
|
---|
[2486] | 191 | PILabel* lab_thrcmd;
|
---|
[165] | 192 |
|
---|
[685] | 193 | PIFileChooser * pfc_fits; // Pour les fichiers FITS
|
---|
| 194 | PIFileChooser * pfc_ppf; // Pour les PPF
|
---|
[2263] | 195 | PIFileChooser * pfc_ascii; // Pour les fichiers ASCII
|
---|
[685] | 196 | PIFileChooser * pfc_ps; // Pour les PostScript
|
---|
[165] | 197 |
|
---|
[1971] | 198 | PIContainer* consolecont; // Container pour la PIConsole
|
---|
[165] | 199 | PIConsole* mCons;
|
---|
[293] | 200 | bool redirecout; // true if stdout/err redirected to mCons;
|
---|
[165] | 201 |
|
---|
| 202 | WindMList mWList;
|
---|
| 203 | BWMList mBWList;
|
---|
| 204 | DrwMList mDrwList;
|
---|
| 205 |
|
---|
| 206 | int mWId,mDId,mBWId;
|
---|
| 207 |
|
---|
| 208 | PIBaseWdg* mCurWdg;
|
---|
| 209 | PIBaseWdg* mLastWdg;
|
---|
| 210 | PIWindow* mCurWin;
|
---|
| 211 | PIZoneWindow* mGrW;
|
---|
| 212 | PIStackWindow* mStW;
|
---|
| 213 | int mGrIdx;
|
---|
| 214 | int mStIdx;
|
---|
| 215 |
|
---|
| 216 | ObjMgrWind* mObjmgrw;
|
---|
| 217 | PPInMgrWind* mPpinmgrw;
|
---|
| 218 |
|
---|
[1971] | 219 | // Attributs graphiques, etc ...
|
---|
[548] | 220 | double mIXmin, mIXmax, mIYmin, mIYmax;
|
---|
[1971] | 221 | bool mAddTitle;
|
---|
| 222 | unsigned int mAxesFlags;
|
---|
[165] | 223 |
|
---|
[1971] | 224 | vector<string> mDefaultAtt;
|
---|
| 225 | vector<string> mAxesAtt;
|
---|
| 226 |
|
---|
| 227 | // Controles et gestion divers
|
---|
[165] | 228 | PIMessage mFCMsg; // Message for processing FileOpen
|
---|
[1971] | 229 | int mFgScSz; // Flag ScreenSize
|
---|
[165] | 230 | bool mFgCWImg; // true -> Current Widget is PIImage
|
---|
[2106] | 231 |
|
---|
| 232 | // Pour comptabiliser l'utilisation des ressources
|
---|
| 233 | ResourceUsage resusg;
|
---|
| 234 | PIPeriodic* resupd_periodic;
|
---|
[2188] | 235 |
|
---|
| 236 | // Commande specifie de l'exterieur a executer
|
---|
| 237 | // Pris en charge par resupd_periodic
|
---|
| 238 | string exc_command;
|
---|
| 239 | bool fg_exc_cmd;
|
---|
[2486] | 240 | // Attributs pour controle de thread
|
---|
| 241 | ZMutex thr_glsyn;
|
---|
[2490] | 242 | bool fg_glsynlock; // true: thr_glsyn locke pour traitement evts
|
---|
[2494] | 243 | XtAppContext * _appctx; // Pour CheckPendingEvents() $CHECK$ A supprimer si possible ...
|
---|
[165] | 244 | };
|
---|
| 245 |
|
---|
| 246 | #endif
|
---|