Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-21 08:57:02

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 
0028 #ifndef G4SceneTreeItem_hh
0029 #define G4SceneTreeItem_hh
0030 
0031 #include "G4AttDef.hh"
0032 #include "G4AttValue.hh"
0033 #include "G4VisAttributes.hh"
0034 #include "globals.hh"
0035 
0036 #include <list>
0037 #include <map>
0038 #include <vector>
0039 
0040 class G4SceneTreeItem
0041 {
0042   public:
0043     // A ghost is a touchable we know to be there but know only its path
0044     enum Type
0045     {
0046       unidentified,
0047       root,
0048       model,
0049       pvmodel,  // Physical Volume model - special case 
0050       ghost,
0051       touchable
0052     };
0053 
0054     explicit G4SceneTreeItem(Type type = unidentified) { fType = type; }
0055     ~G4SceneTreeItem() = default;
0056 
0057     // Copy contructor copies the whole tree, i.e., children and all descendants
0058     G4SceneTreeItem(const G4SceneTreeItem&) = default;
0059 
0060     // Assigns the whole tree, i.e., children and all descendants
0061     G4SceneTreeItem& operator= (const G4SceneTreeItem&) = default;
0062 
0063     // Access functions
0064 
0065     Type GetType() const { return fType; }
0066     const G4String& GetTypeString() const { return fTypeMap[fType]; }
0067     void SetType(Type type) { fType = type; }
0068 
0069     const G4String& GetPVPath() const { return fPVPath; }
0070     void SetPVPath(const G4String& PVPath) { fPVPath = PVPath; }
0071 
0072     const G4String& GetDescription() const { return fDescription; }
0073     void SetDescription(const G4String& description) { fDescription = description; }
0074 
0075     const G4String& GetModelType() const { return fModelType; }
0076     void SetModelType(const G4String& modelType) { fModelType = modelType; }
0077 
0078     const G4String& GetModelDescription() const { return fModelDescription; }
0079     void SetModelDescription(const G4String& modelDescription)
0080     { fModelDescription = modelDescription; }
0081 
0082     const G4String& GetFurtherInfo() const { return fFurtherInfo; }
0083     void SetFurtherInfo(const G4String& furtherInfo)
0084     { fFurtherInfo = furtherInfo; }
0085 
0086     const std::map<G4String, G4AttDef>* GetAttDefs() const { return fpAttDefs; }
0087     void SetAttDefs(const std::map<G4String, G4AttDef>* pAttDefs) { fpAttDefs = pAttDefs; };
0088 
0089     std::vector<G4AttValue>* GetAttValues() const { return fpAttValues; }
0090     void SetAttValues(std::vector<G4AttValue>* pAttValues) { fpAttValues = pAttValues; }
0091 
0092     const G4VisAttributes& GetVisAttributes() const { return fVisAttributes; }
0093     G4VisAttributes& AccessVisAttributes() { return fVisAttributes; }
0094     void SetVisAttributes(const G4VisAttributes& visAtts) { fVisAttributes = visAtts; }
0095 
0096     const std::list<G4SceneTreeItem>& GetChildren() const { return fChildren; }
0097     // Insert item at - or rather, just before - pos
0098     std::list<G4SceneTreeItem>::iterator InsertChild(std::list<G4SceneTreeItem>::iterator pos,
0099                                                      const G4SceneTreeItem& item)
0100     {
0101       return fChildren.insert(pos, item);
0102     }
0103     std::list<G4SceneTreeItem>& AccessChildren() { return fChildren; }
0104 
0105     G4bool IsExpanded() const         { return fExpanded; }
0106     void SetExpanded(G4bool expanded) { fExpanded = expanded; }
0107 
0108     // Utility functions
0109 
0110     // Reset visibility of all objects to false - visible objects will then set to true
0111     void ResetVisibility();
0112 
0113     // If found, returns "true" and places iterator in foundIter
0114     G4bool FindTouchableFromRoot(const G4String& fullPathString,
0115                                  std::list<G4SceneTreeItem>::iterator& foundIter);
0116 
0117     // Dump single item, i.e., ignore any children
0118     void DumpSingleItem(std::ostream&, G4int verbosity = 0) const;
0119 
0120     // Dump whole tree
0121     void DumpTree(std::ostream&, G4int verbosity = 0) const;
0122 
0123   private:
0124     Type fType = unidentified;
0125     static std::map<Type, G4String> fTypeMap;
0126     G4String fDescription;
0127     G4String fModelType = "none";
0128     G4String fModelDescription;
0129     G4String fFurtherInfo;  // Intended for a tooltip or equivalent?
0130     G4String fPVPath;
0131     G4VisAttributes fVisAttributes;
0132     const std::map<G4String, G4AttDef>* fpAttDefs = nullptr;
0133     std::vector<G4AttValue>* fpAttValues = nullptr;
0134     std::list<G4SceneTreeItem> fChildren;
0135     G4bool fExpanded = true;
0136 };
0137 
0138 #endif  // G4SceneTreeItem_hh