| 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>
|
|---|
| 11 | #include <functional>
|
|---|
| 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
|
|---|
| 23 | #include PIPERIODIC_H
|
|---|
| 24 |
|
|---|
| 25 | #include "picons.h"
|
|---|
| 26 |
|
|---|
| 27 | #include "piimage.h"
|
|---|
| 28 | #include "pi3dwdg.h"
|
|---|
| 29 | #include "nobjmgr.h"
|
|---|
| 30 | #include "piacmd.h"
|
|---|
| 31 | #include "pisiadw.h"
|
|---|
| 32 | #include "pistzwin.h"
|
|---|
| 33 |
|
|---|
| 34 | #include "pitherm.h"
|
|---|
| 35 |
|
|---|
| 36 | #include "zthread.h"
|
|---|
| 37 | #include "resusage.h"
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 | enum DispWinEnum {Disp_Default, Disp_Next, Disp_Win, Disp_Same, Disp_Stack, Disp_Inset};
|
|---|
| 41 | // Flag de redirection stdout/stderr
|
|---|
| 42 | enum RED_OUTERR_FLG { NORED_OE, CONSRED_OE, DOUBLERED_OE };
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 | typedef map<long, PIWindow*, less<long> > WindMList;
|
|---|
| 46 | typedef map<long, PIWdg*, less<long> > BWMList;
|
|---|
| 47 | typedef map<long, PIDrawer*, less<long> > DrwMList;
|
|---|
| 48 |
|
|---|
| 49 | class PIStdImgApp : public PIApplication {
|
|---|
| 50 | public:
|
|---|
| 51 | PIStdImgApp(bool fgsmall=false, int narg=0, char* arg[]=NULL);
|
|---|
| 52 | ~PIStdImgApp();
|
|---|
| 53 |
|
|---|
| 54 | virtual void Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
|---|
| 55 | virtual void SetReady();
|
|---|
| 56 | virtual void SetBusy();
|
|---|
| 57 | virtual void SetBlocked();
|
|---|
| 58 |
|
|---|
| 59 | // <ZThread> Multithread execution
|
|---|
| 60 | // On redefinit la methode Run pour gestion multithread
|
|---|
| 61 | virtual void Run();
|
|---|
| 62 | inline ZMutex & getMutex() { return thr_glsyn; }
|
|---|
| 63 | inline void LockMutex() { thr_glsyn.lock(); }
|
|---|
| 64 | inline void UnlockMutex(bool fgbr=false)
|
|---|
| 65 | { if (fgbr) thr_glsyn.broadcast(); thr_glsyn.unlock(); }
|
|---|
| 66 | inline bool isGlSyncLocked() { return fg_glsynlock; }
|
|---|
| 67 | int CheckPendingEvents();
|
|---|
| 68 | void CkEvt_LockMutex(); // On fait le lock apres verification de traitement des evenements
|
|---|
| 69 |
|
|---|
| 70 | // Methodes d'Affichage generique
|
|---|
| 71 | int DispImage(P2DArrayAdapter* nouv, string const & name, string const & opt,
|
|---|
| 72 | bool fgimagnav=false, int oid=0, bool fglock=true);
|
|---|
| 73 | int DispScDrawer(PIDrawer* scd, string const & name, string const & opt,
|
|---|
| 74 | string title="", int oid=0, bool fglock=true);
|
|---|
| 75 | int Disp3DDrawer(PIDrawer3D* scd, string const & name, string const & opt,
|
|---|
| 76 | string title="", int oid=0, bool fglock=true);
|
|---|
| 77 |
|
|---|
| 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 |
|
|---|
| 84 | // Fonction d'ajout de texte (provisoire - Aout 99)
|
|---|
| 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);
|
|---|
| 89 | // Ajout de lignes, rectangles, cercles (provisoires - Aout 2001)
|
|---|
| 90 | void AddLine(double xp1, double yp1, double xp2, double yp2,
|
|---|
| 91 | string const& opt, bool fgarrow=false, bool fgcn=false);
|
|---|
| 92 | void AddRectangle(double xp1, double yp1, double xp2, double yp2, string const& opt,
|
|---|
| 93 | bool fgfill=false, bool fgcn=false);
|
|---|
| 94 | void AddCircle(double xc, double yc, double r, string const& opt,
|
|---|
| 95 | bool fgfill=false, bool fgcn=false);
|
|---|
| 96 | void AddOval(double xp, double yp, double dx, double dy, string const& opt,
|
|---|
| 97 | bool fgfill=false, bool fgcn=false);
|
|---|
| 98 | void AddArc(double xc, double yc, double r, double a, double da,
|
|---|
| 99 | string const& opt, bool fgfill=false, bool fgcn=false);
|
|---|
| 100 | void AddArc(double x1, double y1, double x2, double y2,
|
|---|
| 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);
|
|---|
| 104 |
|
|---|
| 105 | // Fonction Ajout de titre de trace
|
|---|
| 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);
|
|---|
| 109 |
|
|---|
| 110 | // Acces au BaseDrawer (PIElDrawer) du PIBaseWdg courant
|
|---|
| 111 | PIDrawer* CurrentElDrawer();
|
|---|
| 112 |
|
|---|
| 113 | void CreateGraphWin(int nx=1, int ny=1, int sx=0, int sy = 0);
|
|---|
| 114 | void CreateStackWin(int sx=0, int sy = 0);
|
|---|
| 115 | PIWindow * GetWindow(DispWinEnum typ, int& sx, int& sy, int& px, int& py, int& flag, char * nom);
|
|---|
| 116 | void SetZone(int nzx=1, int nzy=1);
|
|---|
| 117 | void StackWinNext();
|
|---|
| 118 |
|
|---|
| 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 |
|
|---|
| 124 | void DeleteWindow(PIWindow* w);
|
|---|
| 125 | void DeleteWidget(PIWdg* w, bool dw=true, bool dwin=true);
|
|---|
| 126 | void DelWRsId(int k);
|
|---|
| 127 | bool CheckWRsId(int k);
|
|---|
| 128 | void CloseAllWindows();
|
|---|
| 129 |
|
|---|
| 130 | inline NamedObjMgr* ObjMgr() { return mObjMgr; }
|
|---|
| 131 | inline PIACmd* CmdInterpreter() { return mCmd; }
|
|---|
| 132 | inline SOpExObj* getSOpExObj() { return mSopex; }
|
|---|
| 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 |
|
|---|
| 142 | inline PIMenu* SpecialMenu() { return m[5]; }
|
|---|
| 143 | inline PIMenu* ModulesMenu() { return m[6]; }
|
|---|
| 144 |
|
|---|
| 145 | inline ObjMgrWind* ObjMgrW() { return mObjmgrw; }
|
|---|
| 146 | inline PPInMgrWind* PPInMgrW() { return mPpinmgrw; }
|
|---|
| 147 |
|
|---|
| 148 | // Gestion (show/hide) de la fenetre Stat/ZoomWindow
|
|---|
| 149 | void StatZoomWindowSetVisible(bool fg=true);
|
|---|
| 150 |
|
|---|
| 151 | // Update de l'info de la fenetre stats/ressources
|
|---|
| 152 | void UpdateStatResourceInfo();
|
|---|
| 153 |
|
|---|
| 154 | // Redirection ou Non de StdOut/StdErr
|
|---|
| 155 | void RedirectStdOutErr(RED_OUTERR_FLG redflg=CONSRED_OE);
|
|---|
| 156 | inline RED_OUTERR_FLG HasRedirectedStdOutErr() { return(redirecout); }
|
|---|
| 157 | // Gestion des signaux
|
|---|
| 158 | void CatchSignals(bool fgfpe=true, bool fgsegv=true);
|
|---|
| 159 |
|
|---|
| 160 | void SetInsetLimits(double xmin=0.4, double xmax=0.6, double ymin=0.4, double ymax=0.6);
|
|---|
| 161 | inline void SetAutoAddTitle(bool aatit=true) { mAddTitle = aatit; }
|
|---|
| 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);
|
|---|
| 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 | }
|
|---|
| 173 |
|
|---|
| 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 |
|
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 | NamedObjMgr* mObjMgr;
|
|---|
| 194 | PIACmd* mCmd;
|
|---|
| 195 | SOpExObj* mSopex;
|
|---|
| 196 |
|
|---|
| 197 | PIMenu* m[7];
|
|---|
| 198 | PIMenu* mc;
|
|---|
| 199 |
|
|---|
| 200 | PIContainer* statcont; // Container pour les widgets zoom, gimv, cmapv ...
|
|---|
| 201 | PIPixmap* zoom;
|
|---|
| 202 | PIPixmap* gimv;
|
|---|
| 203 | PICMapView* cmapv;
|
|---|
| 204 | // Pour afficher des stats et etat thread command
|
|---|
| 205 | PILabel* lab_mem;
|
|---|
| 206 | PIThermometer* therm_mem;
|
|---|
| 207 | PILabel* lab_cpu;
|
|---|
| 208 | PIThermometer* therm_cpu;
|
|---|
| 209 | PILabel* lab_thrcmd;
|
|---|
| 210 |
|
|---|
| 211 | PIFileChooser * pfc_fits; // Pour les fichiers FITS
|
|---|
| 212 | PIFileChooser * pfc_ppf; // Pour les PPF
|
|---|
| 213 | PIFileChooser * pfc_ascii; // Pour les fichiers ASCII
|
|---|
| 214 | PIFileChooser * pfc_ps; // Pour les PostScript
|
|---|
| 215 |
|
|---|
| 216 | PIContainer* consolecont; // Container pour la PIConsole
|
|---|
| 217 | PIConsole* mCons;
|
|---|
| 218 | RED_OUTERR_FLG redirecout; // flag de redirection vers mCons, ou NORED ou vers mCons+terminal;
|
|---|
| 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 |
|
|---|
| 237 | // Attributs graphiques, etc ...
|
|---|
| 238 | double mIXmin, mIXmax, mIYmin, mIYmax;
|
|---|
| 239 | bool mAddTitle;
|
|---|
| 240 | unsigned int mAxesFlags;
|
|---|
| 241 |
|
|---|
| 242 | vector<string> mDefaultAtt;
|
|---|
| 243 | vector<string> mAxesAtt;
|
|---|
| 244 |
|
|---|
| 245 | // Controles et gestion divers
|
|---|
| 246 | PIMessage mFCMsg; // Message for processing FileOpen
|
|---|
| 247 | int mFgScSz; // Flag ScreenSize
|
|---|
| 248 | bool mFgCWImg; // true -> Current Widget is PIImage
|
|---|
| 249 |
|
|---|
| 250 | // Pour comptabiliser l'utilisation des ressources
|
|---|
| 251 | ResourceUsage resusg;
|
|---|
| 252 | PIPeriodic* resupd_periodic;
|
|---|
| 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;
|
|---|
| 258 | // Attributs pour controle de thread
|
|---|
| 259 | ZMutex thr_glsyn;
|
|---|
| 260 | bool fg_glsynlock; // true: thr_glsyn locke pour traitement evts
|
|---|
| 261 | XtAppContext * _appctx; // Pour CheckPendingEvents() $CHECK$ A supprimer si possible ...
|
|---|
| 262 | };
|
|---|
| 263 |
|
|---|
| 264 | #endif
|
|---|