I'm trying to add a colour to the LogicalVolume which has been renamed to TrackerLogical in Geant4. I get the error that fVisAttributes and visAttributes are undefined although I have defined them in the #include section as .hh files.
The primary framework I have used is that of exampleB1 and I am trying to add color using exampleB5 's approach by applying G4VisAttributes. I have referred to this as a guide: https://github.com/Geant4/geant4/blob/master/examples/basic/B5/src/B5DetectorConstruction.cc
I have included the necessary bits in the #include section as shown in example B5, and have included a line for fVisAttributes in the section B1DetectorConstruction::B1DetectorConstruction() but I get the error messages when I run -jN after adding the following section of code before the last line ( return physWorld) :
visAttributes = new G4VisAttributes(G4Colour(0.9,0.9,0.9)); visAttributes->SetVisibility(false); trackerLogical->SetVisAttributes(visAttributes); fVisAttributes.push_back(visAttributes);
This is the error message I get:
home/neha/G4WORk/B1/src/B1DetectorConstruction.cc: In constructor ‘B1DetectorConstruction::B1DetectorConstruction()’: /home/neha/G4WORk/B1/src/B1DetectorConstruction.cc:53:3: error: class ‘B1DetectorConstruction’ does not have any field named ‘fVisAttributes’ 53 | fVisAttributes() | ^~~~~~~~~~~~~~ /home/neha/G4WORk/B1/src/B1DetectorConstruction.cc: In member function ‘virtual G4VPhysicalVolume* B1DetectorConstruction::Construct()’: /home/neha/G4WORk/B1/src/B1DetectorConstruction.cc:202:2: error: ‘visAttributes’ was not declared in this scope; did you mean ‘G4VisAttributes’? 202 | visAttributes = new G4VisAttributes(G4Colour(0.9,0.9,0.9)); | ^~~~~~~~~~~~~ | G4VisAttributes /home/neha/G4WORk/B1/src/B1DetectorConstruction.cc:205:2: error: ‘fVisAttributes’ was not declared in this scope; did you mean ‘G4VisAttributes’? 205 | fVisAttributes.push_back(visAttributes); | ^~~~~~~~~~~~~~ | G4VisAttributes make: *** [CMakeFiles/exampleB1.dir/build.make:89: CMakeFiles/exampleB1.dir/src/B1DetectorConstruction.cc.o] Error 1 make: *** [CMakeFiles/Makefile2:104: CMakeFiles/exampleB1.dir/all] Error 2 make: *** [Makefile:130: all] Error 2
What is causing the issue and how can I resolve this? I am still a beginner with Geant4 and may need some fundamental explanations (in simple/layman's terms preferably). Thank you!