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