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

Last change on this file since 3366 was 3366, checked in by ansari, 18 years ago

Tentative pour regler le probleme de blocage de piapp suite a affichage de la fefenetre de gestion d'objets.

1/ Protection dans NamedObjMgr() pour eviter deadlock de mutex (ds NamedObjMgr::UpdateObjMgrWindow() en particulier)
2/ Introduction de la classe SOpExObj (fichier piacmd.h .cc) pour execution d'operations sur objets, initiees depuis la boucle d'evts, dans un thread separe.

Reza , 30/10/2007

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