source: Sophya/trunk/SophyaPI/PIext/pistdimgapp.h@ 2743

Last change on this file since 2743 was 2651, checked in by ansari, 21 years ago

Modifications pour l'utilisation viewer PIImageNavigator (ajout commande imagnav) - Reza 18 Fev 2005

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