ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VisCommandsGeometry.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4VisCommandsGeometry.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 
28 // /vis/geometry commands - John Allison 31st January 2006
29 
30 #include "G4VisCommandsGeometry.hh"
31 
32 #include "G4UIcmdWithAString.hh"
33 #include "G4VisManager.hh"
34 #include "G4LogicalVolumeStore.hh"
35 #include "G4UImanager.hh"
36 
37 std::map<G4LogicalVolume*, const G4VisAttributes*>
39 
41 {
42  // Delete all vis atts that were "new". Do something like "restore"
43  // without the "rebuild".
44 }
45 
47 
49 {
50  G4bool omitable;
51  fpCommand = new G4UIcmdWithAString("/vis/geometry/list", this);
52  fpCommand -> SetGuidance("Lists vis attributes of logical volume(s).");
53  fpCommand -> SetGuidance("\"all\" lists all logical volumes.");
54  fpCommand -> SetParameterName("logical-volume-name", omitable = true);
55  fpCommand -> SetDefaultValue("all");
56 }
57 
59 {
60  delete fpCommand;
61 }
62 
64 {
65  return "";
66 }
67 
69 {
71  G4bool found = false;
72  for (size_t iLV = 0; iLV < pLVStore->size(); iLV++ ) {
73  G4LogicalVolume*pLV = (*pLVStore)[iLV];
74  const G4String& logVolName = pLV->GetName();
75  if (newValue == "all" || logVolName == newValue) {
76  const G4VisAttributes* visAtts = pLV->GetVisAttributes();
77  G4cout << "\nLogical Volume \"" << pLV->GetName() << "\":";
78  if (visAtts) {
79  G4cout << '\n' << *visAtts;
80  } else {
81  G4cout << " no vis attributes";
82  }
83  G4cout << G4endl;
84  }
85  if (logVolName == newValue) found = true;
86  }
87  if (newValue != "all" && !found) {
89  G4cerr << "ERROR: Logical volume \"" << newValue
90  << "\" not found in logical volume store." << G4endl;
91  }
92  return;
93  }
94 }
95 
97 
99 {
100  G4bool omitable;
101  fpCommand = new G4UIcmdWithAString("/vis/geometry/restore", this);
102  fpCommand -> SetGuidance("Restores vis attributes of logical volume(s).");
103  fpCommand -> SetParameterName("logical-volume-name", omitable = true);
104  fpCommand -> SetDefaultValue("all");
105 }
106 
108 {
109  delete fpCommand;
110 }
111 
113 {
114  return "";
115 }
116 
118 {
121  size_t nLV = pLVStore->size();
122  size_t iLV;
123  G4LogicalVolume* pLV = 0;
124  G4bool found = false;
125  for (iLV = 0; iLV < nLV; iLV++ ) {
126  pLV = (*pLVStore)[iLV];
127  const G4String& logVolName = pLV->GetName();
128  if (logVolName == newValue) found = true;
129  if (newValue == "all" || logVolName == newValue) {
130  VisAttsMapIterator i = fVisAttsMap.find(pLV);
131  if (i != fVisAttsMap.end()) {
132  const G4VisAttributes* newVisAtts = pLV->GetVisAttributes();
133  const G4VisAttributes* oldVisAtts = i->second;
134  pLV->SetVisAttributes(oldVisAtts);
135  if (verbosity >= G4VisManager::confirmations) {
136  G4cout << "\nLogical Volume \"" << pLV->GetName()
137  << "\": re-setting vis attributes:\nwas: " << *newVisAtts
138  << "\nnow: " << *oldVisAtts
139  << G4endl;
140  }
141  }
142  }
143  }
144  if (newValue != "all" && !found) {
145  if (verbosity >= G4VisManager::errors) {
146  G4cerr << "ERROR: Logical volume \"" << newValue
147  << "\" not found in logical volume store." << G4endl;
148  }
149  return;
150  }
152  G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild");
153  }
154 }