/[PAMELA software]/eventviewer/flight/src/FEVpamevcontrol.cpp
ViewVC logotype

Annotation of /eventviewer/flight/src/FEVpamevcontrol.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Mon Feb 26 17:30:32 2007 UTC (17 years, 9 months ago) by mocchiut
Branch: MAIN
Changes since 1.1: +38 -13 lines
More bugs fixed + CARD position now is correct

1 mocchiut 1.1 #include <math.h>
2     #include <stdio.h>
3     #include <iostream>
4     #include <iomanip>
5     #include <fstream>
6     #include <sstream>
7     #if (__GNUC__ == 3) && (__GNUC_MINOR__ == 2)
8     char* operator+( std::streampos&, char* );
9     #endif
10     //
11     #include <TObjectTable.h>
12     #include <TGClient.h>
13     #include <TGButton.h>
14     #include <TGComboBox.h>
15     #include <TGLabel.h>
16     #include <TGTextEntry.h>
17     #include <TGFrame.h>
18     #include <TGButtonGroup.h>
19     #include <TGProgressBar.h>
20     #include <TGMsgBox.h>
21     #include <TGComboBox.h>
22     #include <TTree.h>
23     #include <TClassEdit.h>
24     #include <TObject.h>
25     #include <TList.h>
26     #include <TSystem.h>
27     #include <TSystemDirectory.h>
28     #include <TString.h>
29     #include <TFile.h>
30     #include <TClass.h>
31     #include <TCanvas.h>
32     #include <TH1.h>
33     #include <TH1F.h>
34     #include <TH2D.h>
35     #include <TLatex.h>
36     #include <TPad.h>
37     #include <TPaveLabel.h>
38     #include <TLine.h>
39     #include <TPolyLine.h>
40     #include <TChain.h>
41     #include <TApplication.h>
42     #include <TVirtualX.h>
43     #include <TGClient.h>
44     #include <TGWindow.h>
45     #include <TEllipse.h>
46     #include <TArrow.h>
47     #include <TStyle.h>
48     //
49     #include <FEVpamevcontrol.h>
50     //
51     ClassImp(PAMevcontrol);
52     ClassImp(CalorimeterCalibration);
53     //
54    
55     using namespace std;
56    
57     void stringcopy(TString& s1, const TString& s2, Int_t from=0, Int_t to=0){
58     if ( to == 0 ){
59     Int_t t2length = s2.Length();
60     s1 = "";
61     to = t2length;
62     };
63     for (Int_t i = from; i<to; i++){
64     s1.Append(s2[i],1);
65     };
66     }
67    
68     void stringappend(TString& s1, const TString& s2){
69     Int_t t2length = s2.Length();
70     for (Int_t i = 0; i<t2length; i++){
71     s1.Append(s2[i],1);
72     };
73     }
74    
75     CalorimeterCalibration::CalorimeterCalibration() {
76     fname = "dw_000000_000.dat";
77     status = 0;
78     for (Int_t i=0; i<2;i++){
79     for (Int_t j=0; j<22;j++){
80     for (Int_t m=0; m<96;m++){
81     mip[i][j][m] = 0.;
82     ermip[i][j][m] = 0.;
83     chi2[i][j][m] = 0.;
84     ndf[i][j][m] = 0.;
85     mask[i][j][m] = 0.;
86     for (Int_t a = 0; a < 4 ; a++){
87     fp[a][i][j][m] = 0.;
88     fpe[a][i][j][m] = 0.;
89     };
90     };
91     };
92     };
93     };
94    
95     PAMevcontrol::PAMevcontrol(const TGWindow *p,UInt_t w,UInt_t h,Variables & var, Levels &level, TCanvas &figure) : TGMainFrame(p, w, h){
96     //
97     SetCleanup(kDeepCleanup);
98     DontCallClose();
99     Connect("CloseWindow()","PAMevcontrol",this,"Terminate()");
100     //
101     clev = &level;
102     cvar = &var;
103     thefigure = &figure;
104     //
105     TGCompositeFrame *cframe1 = new TGCompositeFrame(this, 280, 60, kVerticalFrame);
106     TGCompositeFrame *cframe2 = new TGCompositeFrame(this, 280, 60, kVerticalFrame);
107     TGCompositeFrame *cframe3 = new TGCompositeFrame(this, 280, 60, kVerticalFrame);
108     TGCompositeFrame *cframe4 = new TGCompositeFrame(this, 280, 60, kVerticalFrame);
109     TGGroupFrame *gf = new TGGroupFrame(cframe1, "Appearance");
110     TGGroupFrame *inputf = new TGGroupFrame(cframe2, "Input");
111     TGGroupFrame *jumpf = new TGGroupFrame(cframe3, "Jump to");
112     TGGroupFrame *savef = new TGGroupFrame(cframe4, "Save figure as");
113     //
114     TGHorizontalFrame *htexts = new TGHorizontalFrame(savef,400,800);
115     TGHorizontalFrame *htextsl = new TGHorizontalFrame(cframe4,400,800);
116     TGHorizontalFrame *htext = new TGHorizontalFrame(inputf,400,800);
117     TGHorizontalFrame *htext2 = new TGHorizontalFrame(inputf,400,800);
118     TGHorizontalFrame *htext3 = new TGHorizontalFrame(jumpf,400,800);
119     TGHorizontalFrame *htext4 = new TGHorizontalFrame(jumpf,400,80);
120     TGHorizontalFrame *hframe = new TGHorizontalFrame(this,400,800);
121     TGHorizontalFrame *hframe1 = new TGHorizontalFrame(gf, 280, 50);
122     TGHorizontalFrame *hframe2 = new TGHorizontalFrame(gf, 280, 40);
123     TGHorizontalFrame *hframe3 = new TGHorizontalFrame(gf, 280, 40);
124     TGHorizontalFrame *hframe4 = new TGHorizontalFrame(gf,280,10);
125     TGVerticalFrame *hframe5 = new TGVerticalFrame(hframe4, 280, 40);
126     TGHorizontalFrame *hfrprog = new TGHorizontalFrame(this,400,800);
127     //
128     TGTextEntry *fText = new TGTextEntry(htext, new TGTextBuffer(20),-1);
129     fText->SetText(cvar->thefilename.Data());
130     TGTextButton *Load = new TGTextButton(htext,"Load");
131     Load->Connect("Pressed()","TGTextEntry",fText,"ReturnPressed()");
132     fText->Connect("ReturnPressed()", "PAMevcontrol", this,"SetFilename()");
133     fText->Connect("TabPressed()", "PAMevcontrol", this,"CompleteText()");
134     htext->AddFrame(fText, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY, 0, 5, 5, 5));
135     htext->AddFrame(Load, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,0,5,5,5));
136     inputf->AddFrame(new TGLabel(inputf, new TGHotString("Filename:")));
137     inputf->AddFrame(htext, new TGLayoutHints(kLHintsExpandX));
138     //
139     fText2 = new TGTextEntry(htext2, new TGTextBuffer(20),-1);
140     fText2->SetText(cvar->thefilter.Data());
141     TGTextButton *Load2 = new TGTextButton(htext2,"Load");
142     Load2->Connect("Clicked()","TGTextEntry",fText2,"ReturnPressed()");
143 mocchiut 1.2 Load2->SetToolTipText("Clear box and click to unload file");
144 mocchiut 1.1 fText2->Connect("ReturnPressed()", "PAMevcontrol", this,"SetFilter()");
145     fText2->Connect("TabPressed()", "PAMevcontrol", this,"CompleteText()");
146     htext2->AddFrame(fText2, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY, 0, 5, 5, 5));
147     htext2->AddFrame(Load2, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,0,5,5,5));
148     inputf->AddFrame(new TGLabel(inputf, new TGHotString("Selection file:")));
149     inputf->AddFrame(htext2, new TGLayoutHints(kLHintsExpandX));
150     //
151     cframe2->AddFrame(inputf,new TGLayoutHints(kLHintsExpandX,5,5,5,5));
152     //
153 mocchiut 1.2 fchktof = new TGCheckButton(hframe1, "TOF");
154 mocchiut 1.1 fchktof->Connect("Clicked()","PAMevcontrol", this,"chktof()");
155     if ( cvar->TOF ) fchktof->SetState(kButtonDown);
156     hframe1->AddFrame(fchktof, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,0,5,5,5));
157     //
158 mocchiut 1.2 fchkac = new TGCheckButton(hframe1, "AC");
159 mocchiut 1.1 fchkac->Connect("Clicked()","PAMevcontrol", this,"chkac()");
160     if ( cvar->AC ) fchkac->SetState(kButtonDown);
161     hframe1->AddFrame(fchkac, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,5,25,5,5));
162     //
163 mocchiut 1.2 fchktrk = new TGCheckButton(hframe1, "Tracker");
164 mocchiut 1.1 fchktrk->Connect("Clicked()","PAMevcontrol",this,"chktrk()");
165     if ( cvar->TRK ) fchktrk->SetState(kButtonDown);
166     hframe1->AddFrame(fchktrk, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,10,5,5,5));
167     //
168     gf->AddFrame(hframe1, new TGLayoutHints(kLHintsExpandX));
169     //
170 mocchiut 1.2 fchks4 = new TGCheckButton(hframe2, "S4");
171 mocchiut 1.1 fchks4->Connect("Clicked()","PAMevcontrol",this,"chks4()");
172     if ( cvar->S4 ) fchks4->SetState(kButtonDown);
173     hframe2->AddFrame(fchks4, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,0,15,5,5));
174     //
175 mocchiut 1.2 fchknd = new TGCheckButton(hframe2, "ND");
176 mocchiut 1.1 fchknd->Connect("Clicked()","PAMevcontrol",this,"chknd()");
177     if ( cvar->ND ) fchknd->SetState(kButtonDown);
178     hframe2->AddFrame(fchknd, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,5,25,5,5));
179     //
180 mocchiut 1.2 fchkcalo = new TGCheckButton(hframe2, "Calorimeter");
181 mocchiut 1.1 fchkcalo->Connect("Clicked()","PAMevcontrol",this,"chkcalo()");
182     if ( cvar->CALO ) fchkcalo->SetState(kButtonDown);
183     hframe2->AddFrame(fchkcalo, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,10,2,5,5));
184     //
185     gf->AddFrame(hframe2, new TGLayoutHints(kLHintsExpandX));
186     //
187 mocchiut 1.2 fchkinfo = new TGCheckButton(hframe3, "Infos");
188 mocchiut 1.1 fchkinfo->Connect("Clicked()","PAMevcontrol",this,"chkinfo()");
189     if ( cvar->INFOS ) fchkinfo->SetState(kButtonDown);
190     hframe3->AddFrame(fchkinfo, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,0,5,5,5));
191     //
192 mocchiut 1.2 fchknames = new TGCheckButton(hframe3, "Names");
193 mocchiut 1.1 fchknames->Connect("Clicked()","PAMevcontrol",this,"chknames()");
194     if ( cvar->VINFOS ) fchknames->SetState(kButtonDown);
195     hframe3->AddFrame(fchknames, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,5,5,5,5));
196 mocchiut 1.2 fchkpalette = new TGCheckButton(hframe3, "Palette");
197 mocchiut 1.1 fchkpalette->Connect("Clicked()","PAMevcontrol",this,"chkpalette()");
198     if ( cvar->PALETTE) fchkpalette->SetState(kButtonDown);
199     hframe3->AddFrame(fchkpalette, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,10,5,5,5));
200     gf->AddFrame(hframe3, new TGLayoutHints(kLHintsExpandX));
201     //
202     TGVButtonGroup *group = new TGVButtonGroup(hframe4);
203     bwc0 = new TGRadioButton(group, "Colour");
204     bwc1 = new TGRadioButton(group, "B/W");
205     if ( cvar->bw ){
206     bwc1->SetState(kButtonDown);
207     } else {
208     bwc0->SetState(kButtonDown);
209     };
210     bwc0->Connect("Pressed()", "PAMevcontrol",this,"radiocolor()");
211     bwc1->Connect("Pressed()", "PAMevcontrol",this,"radiobw()");
212     hframe4->AddFrame(group,new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,1,5,5,5));
213     //
214     //
215     ftrks4 = new TGCheckButton(hframe5, "Track in S4/ND");
216     ftrks4->Connect("Clicked()","PAMevcontrol",this,"radiotrack()");
217     if ( cvar->tracknds4) ftrks4->SetState(kButtonDown);
218     hframe5->AddFrame(ftrks4, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,5,2,5,5));
219     ffl0 = new TGCheckButton(hframe5, "Force LEVEL0");
220     ffl0->Connect("Clicked()","PAMevcontrol",this,"forcel0()");
221     if ( cvar->fl0 ) ffl0->SetState(kButtonDown);
222     if ( !cvar->fl0 ) ffl0->SetState(kButtonUp);
223     hframe5->AddFrame(ffl0, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,5,2,5,5));
224     //
225     hframe4->AddFrame(hframe5, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY,10,5,5,5));
226     gf->AddFrame(hframe4, new TGLayoutHints(kLHintsExpandX));
227     //
228     cframe1->AddFrame(gf, new TGLayoutHints(kLHintsExpandX));
229     //
230     TGHButtonGroup *jgroup = new TGHButtonGroup(htext4);
231     jbwc0 = new TGRadioButton(jgroup, "packet ");
232     jbwc1 = new TGRadioButton(jgroup, "progressive");
233     jbwc1->SetState(kButtonDown);
234     jbwc0->Connect("Pressed()", "PAMevcontrol",this,"radioevent()");
235     jbwc1->Connect("Pressed()", "PAMevcontrol",this,"radioprog()");
236     htext4->AddFrame(jgroup,new TGLayoutHints(kLHintsExpandX,1,1,0,0));
237     //
238     TGTextEntry *fText3 = new TGTextEntry(htext3, new TGTextBuffer(6),-1);
239     TGTextButton *Jump = new TGTextButton(htext3,"go");
240     Jump->Connect("Clicked()","TGTextEntry",fText3,"ReturnPressed()");
241     fText3->Connect("ReturnPressed()", "PAMevcontrol", this,"jumpto()");
242     htext3->AddFrame(new TGLabel(htext3, new TGHotString("number")), new TGLayoutHints(kLHintsExpandX,0,0,1,1));
243     htext3->AddFrame(fText3, new TGLayoutHints(kLHintsExpandX, 0, 8, 0, 0));
244     htext3->AddFrame(Jump, new TGLayoutHints(kLHintsExpandX,0,0,0,0));
245     jumpf->AddFrame(htext4, new TGLayoutHints(kLHintsExpandX,0,0,1,1)); //
246     jumpf->AddFrame(htext3, new TGLayoutHints(kLHintsExpandX,0,0,0,1)); //
247     //
248     cframe3->AddFrame(jumpf,new TGLayoutHints(kLHintsExpandX,5,5,5,5));
249     //
250     fText4 = new TGTextEntry(htexts, new TGTextBuffer(18),-1);
251     TGTextButton *save = new TGTextButton(htextsl,"save");
252     save->Connect("Clicked()","TGTextEntry",fText4,"ReturnPressed()");
253     fText4->Connect("ReturnPressed()", "PAMevcontrol", this,"saveas()");
254     fText4->Connect("TabPressed()", "PAMevcontrol", this,"CompleteText()");
255     htexts->AddFrame(fText4, new TGLayoutHints(kLHintsExpandX, 0, 8, 1, 1));
256     //
257     fCombo = new TGComboBox(htexts, 98);
258     fCombo->AddEntry(".ps", 0);
259     fCombo->AddEntry(".eps", 1);
260     fCombo->AddEntry(".gif", 2);
261     fCombo->AddEntry(".jpg", 3);
262     fCombo->AddEntry(".tiff", 4);
263     fCombo->AddEntry(".xpm", 5);
264     fCombo->AddEntry(".pdf", 6);
265     fCombo->AddEntry(".xml", 7);
266     fCombo->AddEntry(".png", 8);
267     fCombo->AddEntry(".svg", 9);
268     fCombo->AddEntry(".root", 10);
269     fCombo->AddEntry(".C", 11);
270     fCombo->Select(0);
271     fCombo->Resize(50,23);
272     // htexts->AddFrame(fCombo, new TGLayoutHints(kLHintsCenterX | kLHintsTop | kLHintsLeft | kLHintsCenterY | kLHintsExpandX, 0, 8, 1, 1));
273     htexts->AddFrame(fCombo, new TGLayoutHints(kLHintsExpandY | kLHintsRight, 2, 2, 2, 1));
274     //
275     htextsl->AddFrame(save, new TGLayoutHints(kLHintsExpandX,0,0,2,1));
276     savef->AddFrame(htexts, new TGLayoutHints(kLHintsExpandX,0,0,2,5));
277     // savef->AddFrame(htextsl, new TGLayoutHints(kLHintsExpandX,5,2,5,2));
278     savef->AddFrame(htextsl, new TGLayoutHints(kLHintsExpandX,8,0,5,2));
279     //
280     cframe4->AddFrame(savef,new TGLayoutHints(kLHintsExpandX,5,5,5,5));
281     //
282     fHProg1 = new TGHProgressBar(hfrprog, TGProgressBar::kFancy, 260);
283     fHProg1->SetBarColor("green");
284     fHProg1->ShowPosition();
285     hfrprog->AddFrame(fHProg1, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY | kLHintsExpandX,5,5,5,5));
286     //
287     //
288     TGTextButton *prev = new TGTextButton(hframe,"< &Back");
289     prev->Connect("Clicked()","PAMevcontrol",this,"prev()");
290     hframe->AddFrame(prev, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
291     //
292     TGTextButton *exit = new TGTextButton(hframe,"E&xit");//,"gApplication->Terminate(0)");
293     exit->Connect("Clicked()","PAMevcontrol",this,"Terminate()");
294     exit->SetToolTipText("Quit the event viewer");
295     hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
296     //
297     bstop = new TGTextButton(hframe,"&Stop");
298     bstop->Connect("Clicked()","PAMevcontrol",this,"stop()");
299     hframe->AddFrame(bstop, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
300     bstop->SetState(kButtonDisabled);
301     //
302     TGTextButton *next = new TGTextButton(hframe,"&Next >");
303     next->Connect("Clicked()","PAMevcontrol",this,"next()");
304     hframe->AddFrame(next, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX,5,5,3,4));
305     //
306     //
307     // AddFrame(htext, new TGLayoutHints(kLHintsExpandX,2,2,15,1));
308     AddFrame(cframe2, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
309     AddFrame(cframe1, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
310     AddFrame(cframe3, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
311     AddFrame(cframe4, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
312     AddFrame(hfrprog, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
313     AddFrame(hframe, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,1,1,1,1));
314     // Set a name to the main frame
315     SetWindowName("PAMELA Event Viewer control panel");
316     // Map all subwindows of main frame
317     MapSubwindows();
318     // Initialize the layout algorithm
319     Resize(GetDefaultSize());
320     // Map main frame
321     MapWindow();
322     }
323    
324     void PAMevcontrol::DIALOG(Int_t ty, TString warn){
325     //
326     // ty = 0 -> INFO, ty = 1 -> WARNING, ty = 3 -> ERROR
327     //
328     Int_t retval;
329     TString title;
330     EMsgBoxIcon mb_icon = kMBIconStop;
331     if ( ty == 0 ){
332     title="INFO";
333     mb_icon = kMBIconAsterisk;
334     };
335     if ( ty == 1 ){
336     title="WARNING!";
337     mb_icon = kMBIconExclamation;
338     };
339     if ( ty == 2 ){
340     title="ERROR!!";
341     mb_icon = kMBIconStop;
342     };
343     new TGMsgBox(gClient->GetRoot(), this, title.Data(), warn.Data(), mb_icon, kMBOk, &retval);
344     }
345    
346    
347     void PAMevcontrol::SetFilename() {
348     TGTextEntry *entry = (TGTextEntry*)gTQSender;
349     TString text = entry->GetText();
350     cvar->thefilename=text.Data();
351     cvar->nevents = 0;
352     cvar->firstevno = 0;
353     cvar->lastevno = 0;
354     if ( cvar->fl0 ) {
355     cvar->fl0 = false;
356     ffl0->SetState(kButtonUp);
357     };
358     cvar->restart = true;
359     cvar->waitforever = false;
360     }
361    
362     void PAMevcontrol::CheckLevel() {
363     if ( clev->file == 2 ){
364     ffl0->SetState(kButtonDisabled);
365     if ( !cvar->tracknds4 ) {
366     ftrks4->SetState(kButtonUp);
367     } else {
368     ftrks4->SetState(kButtonDown);
369     };
370     } else {
371     ftrks4->SetState(kButtonDisabled);
372     if ( !cvar->fl0 ) {
373     ffl0->SetState(kButtonUp);
374     } else {
375     ffl0->SetState(kButtonDown);
376     };
377     };
378     }
379    
380     void PAMevcontrol::SetSearching() {
381     bstop->SetState(kButtonUp);
382     };
383    
384     void PAMevcontrol::StopSearching() {
385     bstop->SetState(kButtonDisabled);
386     };
387    
388 mocchiut 1.2 void PAMevcontrol::RefreshButtons() {
389     if ( cvar->jumprog ){
390     jbwc1->SetState(kButtonDown);
391     } else {
392     jbwc0->SetState(kButtonDown);
393     };
394     if ( cvar->fl0 ){
395     ffl0->SetState(kButtonDown);
396     } else {
397     ffl0->SetState(kButtonUp);
398     };
399     if ( cvar->tracknds4) ftrks4->SetState(kButtonDown);
400     if ( cvar->bw ){
401     bwc1->SetState(kButtonDown);
402     } else {
403     bwc0->SetState(kButtonDown);
404     };
405     if ( cvar->PALETTE) fchkpalette->SetState(kButtonDown); else fchkpalette->SetState(kButtonUp);
406     if ( cvar->VINFOS ) fchknames->SetState(kButtonDown); else fchknames->SetState(kButtonUp);
407     if ( cvar->INFOS ) fchkinfo->SetState(kButtonDown); else fchkinfo->SetState(kButtonUp);
408     if ( cvar->CALO ) fchkcalo->SetState(kButtonDown); else fchkcalo->SetState(kButtonUp);
409     if ( cvar->ND ) fchknd->SetState(kButtonDown); else fchknd->SetState(kButtonUp);
410     if ( cvar->S4 ) fchks4->SetState(kButtonDown); else fchks4->SetState(kButtonUp);
411     if ( cvar->TRK ) fchktrk->SetState(kButtonDown); else fchktrk->SetState(kButtonUp);
412     if ( cvar->AC ) fchkac->SetState(kButtonDown); else fchkac->SetState(kButtonUp);
413     if ( cvar->TOF ) fchktof->SetState(kButtonDown); else fchktof->SetState(kButtonUp);
414     };
415    
416 mocchiut 1.1 void PAMevcontrol::SetFilter() {
417     TGTextEntry *entry = (TGTextEntry*)gTQSender;
418     TString text = entry->GetText();
419     cvar->thefilter=text.Data();
420     cvar->i--;
421     cvar->selex = true;
422     cvar->nevents = 0;
423     cvar->firstevno = 0;
424     cvar->lastevno = 0;
425     cvar->refresh = true;
426     }
427    
428     void PAMevcontrol::CompleteText() {
429     TGTextEntry *entry = (TGTextEntry*)gTQSender;
430     TString text = entry->GetText();
431     Int_t curspos = entry->GetCursorPosition();
432     Int_t ncurspos = 0;
433     TString textrem;
434     stringcopy(textrem,text,curspos,text.Length());
435     text.Resize(curspos);
436     if ( !strcmp(text.Data(),"") ) {
437     stringstream ntext;
438     ntext.str("");
439     ntext << gSystem->ExpandPathName("$HOME");
440     text = ntext.str().c_str();
441     curspos=ntext.str().length();
442     };
443     char *test = gSystem->ExpandPathName(text.Data());
444     const char *dir = gSystem->DirName(test);
445     const char *base = gSystem->BaseName(test);
446     TString lbase = base;
447     Int_t lenbase = lbase.Length();
448     TSystemDirectory *tsd = new TSystemDirectory("",dir);
449     TSystemFile *file;
450     TList *lsmatch = new TList;
451     Int_t numf = 0;
452     Int_t numgo = 0;
453     Int_t charmac = 0;
454     TString tbase;
455     Int_t k = 0;
456     stringstream newtext;
457     TSystemFile *mfile;
458     TSystemFile nfile;
459     TList *lsf = new TList;
460     const char *ctbase;
461     if ( !tsd->GetListOfFiles() ){
462     gVirtualX->Bell(0);
463     goto end;
464     };
465     lsf = tsd->GetListOfFiles();
466     file = (TSystemFile*)lsf->First();
467     //
468     while( (TSystemFile*)lsf->After(file) ){
469     numf++;
470     file = (TSystemFile*)lsf->After(file);
471     if ( !strncmp(file->GetName(),base,lenbase) ){
472     numgo++;
473     lsmatch->AddLast(file);
474     const char *ctbase = file->GetName();
475     tbase = ctbase;
476     charmac = tbase.Length();
477     };
478     };
479     newtext.str("");
480     if ( numgo > 0 ){
481     mfile = (TSystemFile*)lsmatch->First();
482     ctbase = mfile->GetName();
483     while ( (!strcmp(ctbase,"..") || !strcmp(ctbase,".")) && (TSystemFile*)lsmatch->After(mfile) ) {
484     mfile = (TSystemFile*)lsmatch->After(mfile);
485     ctbase = mfile->GetName();
486     };
487     tbase = ctbase;
488     base = ctbase;
489     charmac = tbase.Length();;
490     while( (TSystemFile*)lsmatch->After(mfile) ){
491     mfile = (TSystemFile*)lsmatch->After(mfile);
492     ctbase = mfile->GetName();
493     while ( (!strcmp(ctbase,"..") || !strcmp(ctbase,".")) && (TSystemFile*)lsmatch->After(mfile) ) {
494     mfile = (TSystemFile*)lsmatch->After(mfile);
495     ctbase = mfile->GetName();
496     };
497     tbase = ctbase;
498     k = 0;
499     for ( Int_t i=lenbase; i<=tbase.Length(); i++){
500     if ( !strncmp(tbase.Data(),base,i) && strcmp(tbase.Data(),base) ){
501     k = i;
502     };
503     };
504     if ( k <= charmac){
505     charmac = k;
506     };
507     };
508     gVirtualX->Bell(0);
509     };
510     if ( !charmac ) {
511     gVirtualX->Bell(0);
512     goto end;
513     };
514     tbase.Resize(charmac);
515     if ( !strcmp(dir,"") || !strcmp(dir,"/") ){
516     newtext << "/" << tbase.Data();
517     } else {
518     newtext << dir << "/" << tbase.Data();
519     };
520     nfile = TSystemFile(tbase.Data(),dir);
521     if ( nfile.IsDirectory() && numgo == 1 ) newtext << "/";
522     ncurspos = newtext.str().length();
523     if ( textrem.Length() ) newtext << textrem.Data();
524     entry->SetText(newtext.str().c_str());
525     entry->SetCursorPosition(ncurspos);
526     end:
527     lsf->Clear();
528     lsmatch->Clear();
529     }
530    
531     void PAMevcontrol::saveas() {
532     TString text = fText4->GetText();
533     Int_t sel=fCombo->GetSelected();
534     TString ty;
535     switch (sel){
536     case (0):
537     ty = ".ps";
538     break;
539     case (1):
540     ty = ".eps";
541     break;
542     case (2):
543     ty = ".gif";
544     break;
545     case (3):
546     ty = ".jpg";
547     break;
548     case (4):
549     ty = ".tiff";
550     break;
551     case (5):
552     ty = ".xpm";
553     break;
554     case (6):
555     ty = ".pdf";
556     break;
557     case (7):
558     ty = ".xml";
559     break;
560     case (8):
561     ty = ".png";
562     break;
563     case (9):
564     ty = ".svg";
565     break;
566     case (10):
567     ty = ".root";
568     break;
569     case (11):
570     ty = ".C";
571     break;
572     };
573     if ( sel == 0 ) ty = ".ps";
574     stringstream name;
575     if ( strcmp(text.Data(),"") ){
576     name.str("");
577     name << text.Data();
578     name << ty.Data();
579     thefigure->SaveAs(name.str().c_str());
580     name.str("");
581     name << " Saved as ";
582     name << text.Data();
583     name << ty.Data();
584     DIALOG(0,name.str().c_str());
585     printf(" Saved as %s%s \n",text.Data(),ty.Data());
586     };
587     }
588    
589     void PAMevcontrol::increment(float val) {
590     fHProg1->Reset();
591     fHProg1->SetPosition(val);
592     gSystem->ProcessEvents();
593     }
594    
595     void PAMevcontrol::forcel0() {
596     if ( cvar->fl0 ) {
597     cvar->fl0 = false;
598     } else {
599     cvar->fl0 = true;
600     };
601     cvar->alrforc = false;
602     cvar->i--;
603     cvar->nevents = 0;
604     cvar->firstevno = 0;
605     cvar->lastevno = 0;
606     cvar->refresh = true;
607     }
608    
609     void PAMevcontrol::clearselfi(){
610     fText2->SetText("");
611     }
612    
613     void PAMevcontrol::upgrnamfi(){
614     fText4->SetText(cvar->svas.Data());
615     fText4->SetCursorPosition(fText4->GetMaxLength());
616     }
617    
618     void PAMevcontrol::jumpto() {
619     TGTextEntry *entry = (TGTextEntry*)gTQSender;
620     TString text = entry->GetText();
621     Int_t j;
622     j = atoi(text.Data());
623     if ( cvar->jumprog ){
624     if ( j < 1 || j > cvar->nevents ) {
625     printf("\n You can choose between 1 and %i \n",(int)cvar->nevents);
626     stringstream warning;
627     warning.str("");
628     warning << "You can choose between 1 and ";
629     warning << (int)cvar->nevents;
630     DIALOG(1,warning.str().c_str());
631     } else {
632     stringstream warning;
633     // warning.str("");
634     // warning << "Jumping to progressive number ";
635     // warning << j;
636     // DIALOG(0,warning.str().c_str());
637     printf("\n Jumping to progressive number %i\n\n",j);
638     cvar->i = j-2;
639     cvar->goon = true;
640     SetSearching();
641     };
642     } else {
643     if ( j < cvar->firstevno || j > cvar->lastevno ) {
644     printf("\n You can choose between %i and %i \n",cvar->firstevno,cvar->lastevno);
645     stringstream warning;
646     warning.str("");
647     warning << "You can choose between ";
648     warning << cvar->firstevno;
649     warning << " and ";
650     warning << cvar->lastevno;
651     DIALOG(1,warning.str().c_str());
652     } else {
653     // stringstream warning;
654     // warning.str("");
655     // warning << "Jumping to event number ";
656     // warning << j;
657     // DIALOG(0,warning.str().c_str());
658     printf("\n Jumping to packet number %i\n\n",j);
659     cvar->jumpto = j;
660     cvar->jumpen = true;
661     cvar->goon = true;
662     SetSearching();
663     };
664     };
665     entry->SetText("");
666     }
667    
668     void PAMevcontrol::radioevent() {
669     cvar->jumprog = false;
670     }
671    
672     void PAMevcontrol::radioprog() {
673     cvar->jumprog = true;
674     }
675    
676     void PAMevcontrol::radiocolor() {
677     if ( !cvar->goon ){
678     if ( cvar->bw ) {
679     cvar->bw = 0;
680     cvar->i--;
681     cvar->goon = true;
682     };
683     };
684     }
685    
686     void PAMevcontrol::radiobw() {
687     if ( !cvar->goon ){
688     if ( !cvar->bw ) {
689     cvar->bw = 1;
690     cvar->i--;
691     cvar->goon = true;
692     };
693     };
694     }
695    
696     void PAMevcontrol::radiotrack() {
697     if ( cvar->tracknds4 ) {
698     cvar->tracknds4 = 0;
699     } else {
700     cvar->tracknds4 = 1;
701     };
702     cvar->i--;
703     cvar->goon = true;
704     }
705    
706     void PAMevcontrol::chktof() {
707     if ( cvar->TOF ) {
708     cvar->TOF = 0;
709     } else {
710     cvar->TOF = 1;
711     };
712     cvar->i--;
713     cvar->nevents = 0;
714     cvar->firstevno = 0;
715     cvar->lastevno = 0;
716     cvar->refresh = true;
717     }
718    
719     void PAMevcontrol::chkac() {
720     if ( cvar->AC ) {
721     cvar->AC = 0;
722     } else {
723     cvar->AC = 1;
724     };
725     cvar->i--;
726     cvar->nevents = 0;
727     cvar->firstevno = 0;
728     cvar->lastevno = 0;
729     cvar->refresh = true;
730     }
731    
732     void PAMevcontrol::chktrk() {
733     if ( cvar->TRK ) {
734     cvar->TRK = 0;
735     } else {
736     cvar->TRK = 1;
737     };
738     cvar->i--;
739     cvar->nevents = 0;
740     cvar->firstevno = 0;
741     cvar->lastevno = 0;
742     cvar->refresh = true;
743     }
744    
745     void PAMevcontrol::chkcalo() {
746     if ( cvar->CALO ) {
747     cvar->CALO = 0;
748     } else {
749     cvar->CALO = 1;
750     };
751     cvar->i--;
752     cvar->nevents = 0;
753     cvar->firstevno = 0;
754     cvar->lastevno = 0;
755     cvar->refresh = true;
756     }
757    
758     void PAMevcontrol::chks4() {
759     if ( cvar->S4 ) {
760     cvar->S4 = 0;
761     } else {
762     cvar->S4 = 1;
763     };
764     cvar->i--;
765     cvar->nevents = 0;
766     cvar->firstevno = 0;
767     cvar->lastevno = 0;
768     cvar->refresh = true;
769     }
770    
771     void PAMevcontrol::chknd() {
772     if ( cvar->ND ) {
773     cvar->ND = 0;
774     } else {
775     cvar->ND = 1;
776     };
777     cvar->i--;
778     cvar->nevents = 0;
779     cvar->firstevno = 0;
780     cvar->lastevno = 0;
781     cvar->refresh = true;
782     }
783    
784     void PAMevcontrol::chkinfo() {
785     if ( cvar->INFOS ) {
786     cvar->INFOS = 0;
787     } else {
788     cvar->INFOS = 1;
789     };
790     cvar->i--;
791     cvar->goon = true;
792     }
793    
794     void PAMevcontrol::chknames() {
795     if ( cvar->VINFOS ) {
796     cvar->VINFOS = 0;
797     } else {
798     cvar->VINFOS = 1;
799     };
800     cvar->i--;
801     cvar->goon = true;
802     }
803    
804     void PAMevcontrol::chkpalette() {
805     if ( cvar->PALETTE ) {
806     cvar->PALETTE = 0;
807     } else {
808     cvar->PALETTE = 1;
809     };
810     cvar->i--;
811     cvar->goon = true;
812     }
813    
814     void PAMevcontrol::next() {
815     SetSearching();
816     if ( cvar->i == cvar->nevents-1 ) {
817     printf("This is the last event, you can't go forward! \n");
818     DIALOG(1,"This is the last event!");
819     } else {
820     cvar->goon = true;
821     cvar->doflag = 1;
822     };
823     }
824    
825     void PAMevcontrol::stop() {
826     DIALOG(1,"Stop searching");
827     cvar->doflag = 3;
828     }
829    
830     void PAMevcontrol::prev() {
831     SetSearching();
832     if ( cvar->i > 0 ) {
833     printf("WARNING: going backward!\n\n");
834     cvar->doflag = 2;
835     cvar->goon = true;
836     } else {
837     printf("This is the first event, you can't go backward! \n");
838     DIALOG(1,"This is the first event!");
839     };
840     }
841    
842     void PAMevcontrol::Terminate() {
843     gSystem->ProcessEvents();
844     gApplication->Terminate(0);
845     }
846    
847     PAMevcontrol::~PAMevcontrol() {
848     // Clean up used widgets: frames, buttons, layouthints
849     Cleanup();
850     delete this;
851     }

  ViewVC Help
Powered by ViewVC 1.1.23