1 /**************************************************************************
2 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /////////////////////////////////////////////////////////////////////////
17 // ALICE DETECTOR FRAME CLASS //
18 // Author: Mayeul ROUSSELET //
19 // e-mail: Mayeul.Rousselet@cern.ch //
20 // Last update:26/08/2003 //
21 /////////////////////////////////////////////////////////////////////////
27 #include <TObjArray.h>
29 #include "AliDetectorFrame.h"
30 #include "AliDisplay2.h"
31 #include "AliModuleInfo.h"
33 #include "AliModule.h"
35 ClassImp(AliDetectorFrame)
37 int AliDetectorFrame::fgBaseId = 1000;
39 //_____________________________________________________________
40 AliDetectorFrame::AliDetectorFrame(const TGWindow *p, Int_t w, Int_t h,UInt_t bgc)
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;
54 fCheckedMode = kFALSE;
55 for(Int_t i=0;i<gAliDisplay2->GetNbModules();i++){
56 mod = dynamic_cast<AliModule*> (gAliDisplay2->GetModules()->At(i));
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);
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));
86 //_____________________________________________________________
87 AliDetectorFrame::~AliDetectorFrame()
90 for(Int_t i=0;i<gAliDisplay2->GetNbModules();i++){
91 delete fCheckButton[i];
94 delete fCheckedButton;
95 delete fCheckButtonId;
96 //delete [] fDetectorName;
100 delete fButtonInvert;
103 //_____________________________________________________________
104 void AliDetectorFrame::DoButton(Int_t /*pos*/)
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;
114 for(Int_t i=0;i<gAliDisplay2->GetNbModules();i++){
115 mo = dynamic_cast<AliModule *> (gAliDisplay2->GetModules()->At(i));
117 fCheckButton[i]->SetState(kButtonDown);
118 fCheckedButton[i]=kTRUE;
119 gAliDisplay2->EnableDetector(mo->GetName());
123 case kIdbSelectINVERT:{
124 for(Int_t i=0;i<gAliDisplay2->GetNbModules();i++){
125 mo = dynamic_cast<AliModule *> (gAliDisplay2->GetModules()->At(i));
127 if(fCheckedButton[i]==kTRUE) {
128 fCheckButton[i]->SetState(kButtonUp);
129 fCheckedButton[i]=kFALSE;
130 gAliDisplay2->DisableDetector(mo->GetName());
132 else if(fCheckedButton[i]==kFALSE) {
133 fCheckButton[i]->SetState(kButtonDown);
134 fCheckedButton[i]=kTRUE;
135 gAliDisplay2->EnableDetector(mo->GetName());
142 gAliDisplay2->Update(kmMODULES);
143 fCheckedMode = kTRUE;
146 //_____________________________________________________________
147 void AliDetectorFrame::DoCheckButton(Int_t /*pos*/)
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();
155 for(Int_t i=0;i<gAliDisplay2->GetNbModules();i++){
156 mo = dynamic_cast<AliModule *> (gAliDisplay2->GetModules()->At(i));
158 if(id==fCheckButtonId[i]){
159 if(fCheckedButton[i]==kTRUE) {
160 fCheckedButton[i]=kFALSE;
161 gAliDisplay2->DisableDetector(mo->GetName());
164 fCheckedButton[i]=kTRUE;
165 gAliDisplay2->EnableDetector(mo->GetName());
169 gAliDisplay2->Update(kmMODULES);
172 //_____________________________________________________________
173 void AliDetectorFrame::DoSpecific() const
176 TGFrame *frame = (TGFrame *) gTQSender;
177 TGCheckButton *bu= (TGCheckButton *) frame;
178 Int_t id = bu->WidgetId();
180 for(Int_t i=0;i<gAliDisplay2->GetNbModules();i++){
181 mo = dynamic_cast<AliModule *> (gAliDisplay2->GetModules()->At(i));
183 if(id==fCheckButtonId[i]){
184 gAliDisplay2->DrawDetector(mo->GetName());