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