]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4VolumesFrames.cxx
added comment only
[u/mrichter/AliRoot.git] / TGeant4 / TG4VolumesFrames.cxx
1 // $Id$
2 // Category: interfaces
3 //
4 // Author: D. Adamova
5 //
6 //========================================================
7 //
8 //------------TG4VolumesFrames.cxx--------------------------------//
9 //--------- Frames for the the display of volumes properties---//
10 //
11 //========================================================= 
12  
13 #include "TG4VolumesFrames.h"
14 #include "TG4Globals.h" 
15
16 #include <TGTextBuffer.h>
17 #include <TGTextEntry.h>
18 #include <TGComboBox.h>
19 #include <TGLabel.h>
20 #include <TGTab.h>
21 #include <TGFrame.h>
22
23 #include <G4LogicalVolumeStore.hh>
24 #include <G4LogicalVolume.hh>
25 #include <G4Material.hh>
26 #include <G4VSolid.hh>
27  
28  
29  ClassImp(TG4VolumesFrames)
30
31 TG4VolumesFrames::TG4VolumesFrames( TGTab* Tab, TGMainFrame* ActionFrame)
32
33 //---> creates the volumes properties display frame
34 //---> and plunges it into the main frame
35    TGCompositeFrame* parent = Tab->AddTab("Volumes Properties");
36    fCapFrame = new TGCompositeFrame(parent, 60, 20, kHorizontalFrame);
37    ULong_t back= TGFrame::GetBlackPixel(); 
38    fCapFrame->ChangeBackground(back);
39    fVolSubframe1 = new TGCompositeFrame(fCapFrame, 60, 20, kVerticalFrame);
40    fVolFrameLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
41
42 // ComboBox for lvolumes
43    fVolumesCombo = new TGComboBox(fVolSubframe1, 100);
44    TGLayoutHints* lLayoutHints3 = 
45              new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
46                            2, 2, 2, 2);   
47    Text_t* lComboLabelText = " Pick up a volume here ";
48    fComboLabel = new TGLabel( fVolSubframe1, lComboLabelText);
49    fVolSubframe1->AddFrame(fComboLabel, lLayoutHints3);
50    fVolSubframe1->AddFrame(fVolumesCombo, fVolFrameLayout);
51
52    fVolumesCombo->Resize(200, 20);
53    fVolumesCombo->Associate(ActionFrame); 
54
55    
56 // text labels with lvolumes properties 
57
58    Text_t* labelText[3]  = 
59    {"Shape's Name", 
60     "Material    ",
61     "User Limits " }; 
62
63 // Entries for lvolumes properties
64    TGLayoutHints* lLayoutHints4   = 
65        new TGLayoutHints(kLHintsTop | kLHintsExpandY, 5, 5, 5, 5);
66    TGLayoutHints* lLayoutHints5 = 
67        new TGLayoutHints(kLHintsLeft | kLHintsExpandX );
68    fVolSubframe2 = new TGCompositeFrame(fCapFrame, 60, 20, kVerticalFrame);
69
70    { // local scope for i
71      for (Int_t i=0; i<3; i++) {
72        Int_t idT=i+1;   
73        fHframe[i] = new TGHorizontalFrame(fVolSubframe2, 500, 100, kFixedWidth);
74        fVolSubframe2->AddFrame(fHframe[i], lLayoutHints4);
75        fVolTextBuff[i] = new TGTextBuffer(200);
76        fVolTextEntry[i] = new TGTextEntry(fHframe[i], fVolTextBuff[i], 300);
77        fLabel[i] = new TGLabel(fHframe[i], labelText[i]);
78        fHframe[i]->AddFrame(fLabel[i], lLayoutHints5);
79        fHframe[i]->AddFrame(fVolTextEntry[i], lLayoutHints5);
80        fVolTextEntry[i]->Associate(ActionFrame); 
81      }
82    } 
83
84 // making up the Volumes frame   
85      fCapFrame->AddFrame(fVolSubframe1,fVolFrameLayout);  
86      fCapFrame->AddFrame(fVolSubframe2,fVolFrameLayout);
87 // going to the main frame     
88      parent->AddFrame(fCapFrame, fVolFrameLayout);
89 }
90
91 TG4VolumesFrames::TG4VolumesFrames(const TG4VolumesFrames& vf) 
92 {
93 // Dummy copy constructor 
94   TG4Globals::Exception(
95     "Attempt to use TG4VolumesFrames copy constructor.");
96 }
97
98 TG4VolumesFrames& TG4VolumesFrames::operator=(const TG4VolumesFrames& vf)
99 {
100   // check assignement to self
101   if (this == &vf) return *this;
102
103   TG4Globals::Exception(
104     "Attempt to assign  singleton.");
105     
106   return *this;  
107 }    
108
109 TG4VolumesFrames::~TG4VolumesFrames()
110 {
111 //---> liquidator 
112
113    G4cout << "\n Now in  TG4VolumesFrames destructor \n" << G4endl;
114    delete fVolSubframe1;
115    delete fVolFrameLayout;
116    delete fVolumesCombo;
117    delete fComboLabel;
118    delete fVolSubframe2;
119    delete fCapFrame;
120   
121    Int_t i;
122    for (i=0; i<3; i++) {
123      delete fHframe[i];
124      delete fVolTextBuff[i];
125      delete fVolTextEntry[i];
126      delete fLabel[i];
127    }
128
129 }
130
131 void TG4VolumesFrames::SetVolumesComboEntries() 
132 {
133 //--->//---> puts names of lvolumes into the combo box entries
134
135     G4LogicalVolumeStore* lComboEntries = G4LogicalVolumeStore::GetInstance();
136
137     G4int ig = lComboEntries->size();
138     G4String name;
139     
140     for (int ii=0; ii < ig; ii++)
141         { name = ((*lComboEntries )[ii])->GetName() ;
142           AddLogicalVolumeName( name, ii+1);
143         };
144         
145     name = "  " ;
146     AddLogicalVolumeName( name, ig+1);
147         
148     
149 }
150
151 void TG4VolumesFrames::AddLogicalVolumeName( const char* name, Int_t index) const
152 {
153 //-----> adds an lvolume name to the combo box  
154
155    fVolumesCombo->AddEntry( name, index);
156    fVolumesCombo->Select(index);
157    fVolumesCombo->Resize(200, 20);
158 }
159
160 void TG4VolumesFrames::DisplayVolumeCharacteristics()
161 {
162 //-----> shows informations about a logical volume 
163
164    G4LogicalVolumeStore* lComboEntries = G4LogicalVolumeStore::GetInstance();
165    G4int ientr = lComboEntries->size();
166    G4int index = fVolumesCombo->GetSelected();
167    
168    G4cout << "\nThe clicked-on volumes entry has the index:  " << index << G4endl;
169
170    if( index < ientr+1 ) {
171    
172      G4int ii = index-1;
173      G4LogicalVolume* lVolume = (*lComboEntries )[ii];
174      G4Material* lvMaterial = ((*lComboEntries )[ii])->GetMaterial();
175
176      G4cout << lVolume->GetName() << "  " 
177             << lVolume->GetSolid()->GetEntityType() << "  "
178             << lvMaterial->GetName() << "  "
179             << lVolume->GetUserLimits() << "  "
180             << G4endl;
181           
182           
183    char buff[100];
184    
185     sprintf(buff, lVolume->GetSolid()->GetEntityType());
186     fVolTextBuff[0]->Clear();
187     fVolTextBuff[0]->AddText(0, buff);
188     gClient->NeedRedraw(fVolTextEntry[0]);
189     
190     sprintf(buff, lvMaterial->GetName());
191     fVolTextBuff[1]->Clear();
192     fVolTextBuff[1]->AddText(0, buff);
193     gClient->NeedRedraw(fVolTextEntry[1]);
194
195     
196     sprintf(buff, "User limits undefined" );
197     if (lVolume->GetUserLimits())
198        sprintf(buff, "User limits defined" ); 
199     fVolTextBuff[2]->Clear();
200     fVolTextBuff[2]->AddText(0, buff);
201     gClient->NeedRedraw(fVolTextEntry[2]);
202    };
203    
204    if( index == ientr+1 ) {
205    
206       for ( G4int ii=0; ii<3; ii++) {
207         fVolTextBuff[ii]->Clear();          
208         gClient->NeedRedraw(fVolTextEntry[ii]);
209         };
210      };
211 }
212