]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | ///////////////////////////////////////////////////////////////////////// | |
17 | // ALICE DETECTOR FRAME CLASS // | |
18 | // Author: Mayeul ROUSSELET // | |
19 | // e-mail: Mayeul.Rousselet@cern.ch // | |
20 | // Last update:26/08/2003 // | |
21 | ///////////////////////////////////////////////////////////////////////// | |
22 | ||
23 | #include <TGWindow.h> | |
24 | #include <TGFrame.h> | |
25 | #include <TGButton.h> | |
26 | #include <TGLayout.h> | |
27 | #include <TObjArray.h> | |
28 | ||
29 | #include "AliDetectorFrame.h" | |
30 | #include "AliDisplay2.h" | |
31 | #include "AliModuleInfo.h" | |
32 | ||
33 | #include "AliModule.h" | |
34 | ||
35 | ClassImp(AliDetectorFrame); | |
36 | ||
37 | int AliDetectorFrame::fgBaseId = 1000; | |
38 | ||
39 | //_____________________________________________________________ | |
40 | AliDetectorFrame::AliDetectorFrame(const TGWindow *p, Int_t w, Int_t h,UInt_t bgc) | |
41 | { | |
42 | // Constructor | |
43 | fMainFrame = new TGCompositeFrame(p,w,h,kVerticalFrame,bgc); | |
44 | TGLayoutHints *layout = new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2,2); | |
45 | TGLayoutHints *layout2 = new TGLayoutHints(kLHintsTop | kLHintsRight,2,2,2,2); | |
46 | TGLayoutHints *layout3 = new TGLayoutHints(kLHintsTop | kLHintsExpandX,2,2,2,2); | |
47 | fCheckButton = new TGCheckButton*[gAliDisplay2->GetNbModules()]; | |
48 | fCheckedButton = new Bool_t[gAliDisplay2->GetNbModules()]; | |
49 | fCheckButtonId = new Int_t[gAliDisplay2->GetNbModules()]; | |
50 | TGCompositeFrame *dframe; | |
51 | TGButton *button; | |
52 | char text[32]; | |
53 | AliModule *mod; | |
54 | fCheckedMode = kFALSE; | |
55 | for(Int_t i=0;i<gAliDisplay2->GetNbModules();i++){ | |
56 | mod = dynamic_cast<AliModule*> (gAliDisplay2->GetModules()->At(i)); | |
57 | if(!mod) continue; | |
58 | dframe = new TGCompositeFrame(fMainFrame,150,20,kHorizontalFrame); | |
59 | fCheckButton[i] = new TGCheckButton(dframe,mod->GetName(),fgBaseId); | |
60 | fCheckButtonId[i]=fgBaseId; | |
61 | fCheckButton[i]->Connect("Clicked()","AliDetectorFrame",this,"DoCheckButton(Int_t)"); | |
62 | fCheckedButton[i]=kTRUE; | |
63 | dframe->AddFrame(fCheckButton[i],layout); | |
64 | fCheckButton[i]->SetState(kButtonDown); | |
65 | sprintf(text,"Specific %s view",mod->GetName()); | |
66 | button = new TGTextButton(dframe,"Display",fgBaseId); | |
67 | button->SetToolTipText(text); | |
68 | button->Connect("Clicked()","AliDetectorFrame",this,"DoSpecific()"); | |
69 | dframe->AddFrame(button,layout2); | |
70 | fMainFrame->AddFrame(dframe,layout3); | |
71 | gAliDisplay2->GetModuleInfo()->SetId((char*)mod->GetName(),fgBaseId); | |
72 | fgBaseId++; | |
73 | } | |
74 | gAliDisplay2->GetModuleInfo()->Print(); | |
75 | fButtonFrame = new TGCompositeFrame(fMainFrame,w,100,kHorizontalFrame,bgc); | |
76 | fButtonAll = new TGTextButton(fButtonFrame,"All",kIdbSelectALL); | |
77 | fButtonAll->Connect("Clicked()","AliDetectorFrame",this,"DoButton(Int_t)"); | |
78 | fButtonFrame->AddFrame(fButtonAll,new TGLayoutHints(kLHintsBottom | kLHintsLeft,2,2,2,2)); | |
79 | fButtonInvert = new TGTextButton(fButtonFrame,"Invert",kIdbSelectINVERT); | |
80 | fButtonInvert->Connect("Clicked()","AliDetectorFrame",this,"DoButton(Int_t)"); | |
81 | fButtonFrame->AddFrame(fButtonInvert,new TGLayoutHints(kLHintsBottom | kLHintsRight,2,2,2,2)); | |
82 | fMainFrame->AddFrame(fButtonFrame,new TGLayoutHints(kLHintsBottom | kLHintsLeft|kLHintsExpandX,0,0,2,2)); | |
83 | fCheckedMode = kTRUE; | |
84 | } | |
85 | ||
86 | //_____________________________________________________________ | |
87 | AliDetectorFrame::~AliDetectorFrame() | |
88 | { | |
89 | // Destructor | |
90 | for(Int_t i=0;i<gAliDisplay2->GetNbModules();i++){ | |
91 | delete fCheckButton[i]; | |
92 | } | |
93 | delete fCheckButton; | |
94 | delete fCheckedButton; | |
95 | delete fCheckButtonId; | |
96 | //delete [] fDetectorName; | |
97 | delete fButtonFrame; | |
98 | delete fMainFrame; | |
99 | delete fButtonAll; | |
100 | delete fButtonInvert; | |
101 | } | |
102 | ||
103 | //_____________________________________________________________ | |
104 | void AliDetectorFrame::DoButton(Int_t /*pos*/) | |
105 | { | |
106 | // Update display if a button was used | |
107 | TGFrame *frame = (TGFrame *) gTQSender; | |
108 | TGButton *bu= (TGButton *) frame; | |
109 | int id = bu->WidgetId(); | |
110 | fCheckedMode = kFALSE; | |
111 | AliModule *mo; | |
112 | switch(id){ | |
113 | case kIdbSelectALL:{ | |
114 | for(Int_t i=0;i<gAliDisplay2->GetNbModules();i++){ | |
115 | mo = dynamic_cast<AliModule *> (gAliDisplay2->GetModules()->At(i)); | |
116 | if(!mo) continue; | |
117 | fCheckButton[i]->SetState(kButtonDown); | |
118 | fCheckedButton[i]=kTRUE; | |
119 | gAliDisplay2->EnableDetector(mo->GetName()); | |
120 | } | |
121 | } | |
122 | break; | |
123 | case kIdbSelectINVERT:{ | |
124 | for(Int_t i=0;i<gAliDisplay2->GetNbModules();i++){ | |
125 | mo = dynamic_cast<AliModule *> (gAliDisplay2->GetModules()->At(i)); | |
126 | if(!mo) continue; | |
127 | if(fCheckedButton[i]==kTRUE) { | |
128 | fCheckButton[i]->SetState(kButtonUp); | |
129 | fCheckedButton[i]=kFALSE; | |
130 | gAliDisplay2->DisableDetector(mo->GetName()); | |
131 | } | |
132 | else if(fCheckedButton[i]==kFALSE) { | |
133 | fCheckButton[i]->SetState(kButtonDown); | |
134 | fCheckedButton[i]=kTRUE; | |
135 | gAliDisplay2->EnableDetector(mo->GetName()); | |
136 | } | |
137 | } | |
138 | } | |
139 | break; | |
140 | default:break; | |
141 | } | |
142 | gAliDisplay2->Update(kmMODULES); | |
143 | fCheckedMode = kTRUE; | |
144 | } | |
145 | ||
146 | //_____________________________________________________________ | |
147 | void AliDetectorFrame::DoCheckButton(Int_t /*pos*/) | |
148 | { | |
149 | // Chech if any button was used | |
150 | if(fCheckedMode == kFALSE) return; | |
151 | TGFrame *frame = (TGFrame *) gTQSender; | |
152 | TGCheckButton *bu= (TGCheckButton *) frame; | |
153 | Int_t id = bu->WidgetId(); | |
154 | AliModule *mo; | |
155 | for(Int_t i=0;i<gAliDisplay2->GetNbModules();i++){ | |
156 | mo = dynamic_cast<AliModule *> (gAliDisplay2->GetModules()->At(i)); | |
157 | if(!mo) continue; | |
158 | if(id==fCheckButtonId[i]){ | |
159 | if(fCheckedButton[i]==kTRUE) { | |
160 | fCheckedButton[i]=kFALSE; | |
161 | gAliDisplay2->DisableDetector(mo->GetName()); | |
162 | } | |
163 | else { | |
164 | fCheckedButton[i]=kTRUE; | |
165 | gAliDisplay2->EnableDetector(mo->GetName()); | |
166 | } | |
167 | } | |
168 | } | |
169 | gAliDisplay2->Update(kmMODULES); | |
170 | } | |
171 | ||
172 | //_____________________________________________________________ | |
173 | void AliDetectorFrame::DoSpecific() const | |
174 | { | |
175 | // Draw detectors | |
176 | TGFrame *frame = (TGFrame *) gTQSender; | |
177 | TGCheckButton *bu= (TGCheckButton *) frame; | |
178 | Int_t id = bu->WidgetId(); | |
179 | AliModule *mo; | |
180 | for(Int_t i=0;i<gAliDisplay2->GetNbModules();i++){ | |
181 | mo = dynamic_cast<AliModule *> (gAliDisplay2->GetModules()->At(i)); | |
182 | if(!mo) continue; | |
183 | if(id==fCheckButtonId[i]){ | |
184 | gAliDisplay2->DrawDetector(mo->GetName()); | |
185 | } | |
186 | } | |
187 | } |