[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;
|
---|
[2651] | 43 | typedef map<long, PIWdg*, less<long> > BWMList;
|
---|
[165] | 44 | typedef map<long, PIDrawer*, less<long> > DrwMList;
|
---|
| 45 |
|
---|
| 46 | class PIStdImgApp : public PIApplication {
|
---|
| 47 | public:
|
---|
[2944] | 48 | PIStdImgApp(bool fgsmall=false, int narg=0, char* arg[]=NULL);
|
---|
[165] | 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();
|
---|
[2800] | 65 | void CkEvt_LockMutex(); // On fait le lock apres verification de traitement des evenements
|
---|
[2486] | 66 |
|
---|
| 67 | // Methodes d'Affichage generique
|
---|
[2491] | 68 | int DispImage(P2DArrayAdapter* nouv, string const & name, string const & opt,
|
---|
[2651] | 69 | bool fgimagnav=false, int oid=0, bool fglock=true);
|
---|
[1971] | 70 | int DispScDrawer(PIDrawer* scd, string const & name, string const & opt,
|
---|
[2491] | 71 | string title="", int oid=0, bool fglock=true);
|
---|
[1971] | 72 | int Disp3DDrawer(PIDrawer3D* scd, string const & name, string const & opt,
|
---|
[2491] | 73 | string title="", int oid=0, bool fglock=true);
|
---|
[165] | 74 |
|
---|
[2188] | 75 | // Specification (de l'exterieur) de commande a executer
|
---|
| 76 | inline void SubmitCommand(string const& cmd)
|
---|
| 77 | { exc_command = cmd; fg_exc_cmd = true; }
|
---|
| 78 | // Execution de commande soumis de l'exterieur
|
---|
| 79 | int ExecuteExtCommand();
|
---|
| 80 |
|
---|
[1642] | 81 | // Fonction d'ajout de texte (provisoire - Aout 99)
|
---|
[2263] | 82 | void AddText(string const & txt, double xp, double yp, string const& opt, bool fgcn=false);
|
---|
| 83 | void AddCompText(string const & txt, string const & txtup, string const & txtdn,
|
---|
| 84 | double xp, double yp, string const& opt,
|
---|
| 85 | string const& optss, bool fgcn=false);
|
---|
[1642] | 86 | // Ajout de lignes, rectangles, cercles (provisoires - Aout 2001)
|
---|
[2243] | 87 | void AddLine(double xp1, double yp1, double xp2, double yp2,
|
---|
[2263] | 88 | string const& opt, bool fgarrow=false, bool fgcn=false);
|
---|
[1971] | 89 | void AddRectangle(double xp1, double yp1, double xp2, double yp2, string const& opt,
|
---|
[2263] | 90 | bool fgfill=false, bool fgcn=false);
|
---|
[1971] | 91 | void AddCircle(double xc, double yc, double r, string const& opt,
|
---|
[2263] | 92 | bool fgfill=false, bool fgcn=false);
|
---|
[2638] | 93 | void AddOval(double xp, double yp, double dx, double dy, string const& opt,
|
---|
| 94 | bool fgfill=false, bool fgcn=false);
|
---|
[2265] | 95 | void AddArc(double xc, double yc, double r, double a, double da,
|
---|
| 96 | string const& opt, bool fgfill=false, bool fgcn=false);
|
---|
[2243] | 97 | void AddArc(double x1, double y1, double x2, double y2,
|
---|
[2263] | 98 | double x3, double y3, string const& opt, bool fgfill=false, bool fgcn=false);
|
---|
| 99 | void AddPoly(vector<double>& x, vector<double>& y,
|
---|
| 100 | string const& opt, bool fgfill=false, bool fgcn=false);
|
---|
[1642] | 101 |
|
---|
[1131] | 102 | // Fonction Ajout de titre de trace
|
---|
[2165] | 103 | void SetTitle(string const & titleup, string const & titledown, string const& opt);
|
---|
| 104 | // Fonction d'Ajout label d'axe X,Y
|
---|
| 105 | void SetAxeLabels(string const & xLabel, string const & yLabel, string const& opt);
|
---|
[349] | 106 |
|
---|
[1642] | 107 | // Acces au BaseDrawer (PIElDrawer) du PIBaseWdg courant
|
---|
[2165] | 108 | PIDrawer* CurrentElDrawer();
|
---|
[349] | 109 |
|
---|
[165] | 110 | void CreateGraphWin(int nx=1, int ny=1, int sx=0, int sy = 0);
|
---|
| 111 | void CreateStackWin(int sx=0, int sy = 0);
|
---|
[1971] | 112 | PIWindow * GetWindow(DispWinEnum typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom);
|
---|
[165] | 113 | void SetZone(int nzx=1, int nzy=1);
|
---|
| 114 | void StackWinNext();
|
---|
| 115 |
|
---|
[3355] | 116 | // Pour specifier le widget pour le trace en superpose, en specifiant un nom de widget
|
---|
| 117 | void SelectLastWidget(string & nom);
|
---|
| 118 | // Pour specifier le widget pour le trace en superpose, en specifiant un nom d'objet
|
---|
| 119 | void SelectLastWidgetByObjName(string & nom);
|
---|
| 120 |
|
---|
[165] | 121 | void DeleteWindow(PIWindow* w);
|
---|
[2651] | 122 | void DeleteWidget(PIWdg* w, bool dw=true, bool dwin=true);
|
---|
[165] | 123 | void DelWRsId(int k);
|
---|
[368] | 124 | bool CheckWRsId(int k);
|
---|
[165] | 125 | void CloseAllWindows();
|
---|
| 126 |
|
---|
| 127 | inline NamedObjMgr* ObjMgr() { return mObjMgr; }
|
---|
| 128 | inline PIACmd* CmdInterpreter() { return mCmd; }
|
---|
| 129 |
|
---|
| 130 | PIWindow* CurrentWindow() { return (mCurWin); };
|
---|
| 131 | PIBaseWdg* CurrentBaseWdg() { return (mCurWdg); };
|
---|
| 132 |
|
---|
| 133 | inline PIPixmap* ZoomW() { return zoom; }
|
---|
| 134 | inline PIPixmap* GloVW() { return gimv; }
|
---|
| 135 | inline PICMapView* CMapVW() { return cmapv; }
|
---|
| 136 | inline PIConsole* GetConsole() { return mCons; }
|
---|
| 137 |
|
---|
[293] | 138 | inline PIMenu* SpecialMenu() { return m[5]; }
|
---|
| 139 | inline PIMenu* ModulesMenu() { return m[6]; }
|
---|
[165] | 140 |
|
---|
| 141 | inline ObjMgrWind* ObjMgrW() { return mObjmgrw; }
|
---|
| 142 | inline PPInMgrWind* PPInMgrW() { return mPpinmgrw; }
|
---|
| 143 |
|
---|
[1971] | 144 | // Gestion (show/hide) de la fenetre Stat/ZoomWindow
|
---|
| 145 | void StatZoomWindowSetVisible(bool fg=true);
|
---|
| 146 |
|
---|
[2106] | 147 | // Update de l'info de la fenetre stats/ressources
|
---|
| 148 | void UpdateStatResourceInfo();
|
---|
| 149 |
|
---|
[165] | 150 | // Redirection ou Non de StdOut/StdErr
|
---|
| 151 | void RedirectStdOutErr(bool fg = true);
|
---|
[293] | 152 | inline bool HasRedirectedStdOutErr() { return(redirecout); }
|
---|
[165] | 153 | // Gestion des signaux
|
---|
[374] | 154 | void CatchSignals(bool fgfpe=true, bool fgsegv=true);
|
---|
[165] | 155 |
|
---|
[548] | 156 | void SetInsetLimits(double xmin=0.4, double xmax=0.6, double ymin=0.4, double ymax=0.6);
|
---|
[1131] | 157 | inline void SetAutoAddTitle(bool aatit=true) { mAddTitle = aatit; }
|
---|
[1971] | 158 | void SetAxesAtt(unsigned int axfl) { mAxesFlags = axfl; }
|
---|
| 159 | // void SaveGraphicAtt();
|
---|
| 160 | // void RestoreGraphicAtt();
|
---|
| 161 | void SetDefaultGraphicAttributes(string const & opt);
|
---|
| 162 | void SetDefaultAxesAttributes(string const & opt);
|
---|
[3355] | 163 | DispWinEnum ParseDisplayOption(string const & opt, vector<string>& opts, string& wname);
|
---|
| 164 | inline DispWinEnum ParseDisplayOption(string const & opt, vector<string>& opts)
|
---|
| 165 | {
|
---|
| 166 | string wname;
|
---|
| 167 | return ParseDisplayOption(opt, opts, wname);
|
---|
| 168 | }
|
---|
[506] | 169 |
|
---|
[165] | 170 | // Gestion fichiers PS
|
---|
| 171 | int num_eps;
|
---|
| 172 | PSFile *mpsfile;
|
---|
| 173 | string name_ps;
|
---|
| 174 |
|
---|
| 175 | // Gestion OUT-PPF
|
---|
| 176 | POutPersist* mPpfout;
|
---|
| 177 | string name_outppf;
|
---|
| 178 |
|
---|
| 179 | private:
|
---|
| 180 | void MBProcess1(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
| 181 | void MBProcess2(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
| 182 | void MBProcess3(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
| 183 | void MBProcess4(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
| 184 | void MBProcess5(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
| 185 | void MBProcess6(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
| 186 |
|
---|
[1971] | 187 |
|
---|
[165] | 188 |
|
---|
| 189 | NamedObjMgr* mObjMgr;
|
---|
| 190 | PIACmd* mCmd;
|
---|
| 191 |
|
---|
[293] | 192 | PIMenu* m[7];
|
---|
[165] | 193 | PIMenu* mc;
|
---|
| 194 |
|
---|
[1971] | 195 | PIContainer* statcont; // Container pour les widgets zoom, gimv, cmapv ...
|
---|
[165] | 196 | PIPixmap* zoom;
|
---|
| 197 | PIPixmap* gimv;
|
---|
| 198 | PICMapView* cmapv;
|
---|
[2486] | 199 | // Pour afficher des stats et etat thread command
|
---|
[2106] | 200 | PILabel* lab_mem;
|
---|
| 201 | PIThermometer* therm_mem;
|
---|
| 202 | PILabel* lab_cpu;
|
---|
| 203 | PIThermometer* therm_cpu;
|
---|
[2486] | 204 | PILabel* lab_thrcmd;
|
---|
[165] | 205 |
|
---|
[685] | 206 | PIFileChooser * pfc_fits; // Pour les fichiers FITS
|
---|
| 207 | PIFileChooser * pfc_ppf; // Pour les PPF
|
---|
[2263] | 208 | PIFileChooser * pfc_ascii; // Pour les fichiers ASCII
|
---|
[685] | 209 | PIFileChooser * pfc_ps; // Pour les PostScript
|
---|
[165] | 210 |
|
---|
[1971] | 211 | PIContainer* consolecont; // Container pour la PIConsole
|
---|
[165] | 212 | PIConsole* mCons;
|
---|
[293] | 213 | bool redirecout; // true if stdout/err redirected to mCons;
|
---|
[165] | 214 |
|
---|
| 215 | WindMList mWList;
|
---|
| 216 | BWMList mBWList;
|
---|
| 217 | DrwMList mDrwList;
|
---|
| 218 |
|
---|
| 219 | int mWId,mDId,mBWId;
|
---|
| 220 |
|
---|
| 221 | PIBaseWdg* mCurWdg;
|
---|
| 222 | PIBaseWdg* mLastWdg;
|
---|
| 223 | PIWindow* mCurWin;
|
---|
| 224 | PIZoneWindow* mGrW;
|
---|
| 225 | PIStackWindow* mStW;
|
---|
| 226 | int mGrIdx;
|
---|
| 227 | int mStIdx;
|
---|
| 228 |
|
---|
| 229 | ObjMgrWind* mObjmgrw;
|
---|
| 230 | PPInMgrWind* mPpinmgrw;
|
---|
| 231 |
|
---|
[1971] | 232 | // Attributs graphiques, etc ...
|
---|
[548] | 233 | double mIXmin, mIXmax, mIYmin, mIYmax;
|
---|
[1971] | 234 | bool mAddTitle;
|
---|
| 235 | unsigned int mAxesFlags;
|
---|
[165] | 236 |
|
---|
[1971] | 237 | vector<string> mDefaultAtt;
|
---|
| 238 | vector<string> mAxesAtt;
|
---|
| 239 |
|
---|
| 240 | // Controles et gestion divers
|
---|
[165] | 241 | PIMessage mFCMsg; // Message for processing FileOpen
|
---|
[1971] | 242 | int mFgScSz; // Flag ScreenSize
|
---|
[165] | 243 | bool mFgCWImg; // true -> Current Widget is PIImage
|
---|
[2106] | 244 |
|
---|
| 245 | // Pour comptabiliser l'utilisation des ressources
|
---|
| 246 | ResourceUsage resusg;
|
---|
| 247 | PIPeriodic* resupd_periodic;
|
---|
[2188] | 248 |
|
---|
| 249 | // Commande specifie de l'exterieur a executer
|
---|
| 250 | // Pris en charge par resupd_periodic
|
---|
| 251 | string exc_command;
|
---|
| 252 | bool fg_exc_cmd;
|
---|
[2486] | 253 | // Attributs pour controle de thread
|
---|
| 254 | ZMutex thr_glsyn;
|
---|
[2490] | 255 | bool fg_glsynlock; // true: thr_glsyn locke pour traitement evts
|
---|
[2494] | 256 | XtAppContext * _appctx; // Pour CheckPendingEvents() $CHECK$ A supprimer si possible ...
|
---|
[165] | 257 | };
|
---|
| 258 |
|
---|
| 259 | #endif
|
---|