Geant4  10.02.p01
G4Scene.hh
Go to the documentation of this file.
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 // $Id: G4Scene.hh 66373 2012-12-18 09:41:34Z gcosmo $
28 //
29 //
30 // Scene John Allison 19th July 1996.
31 //
32 // Class Description:
33 //
34 // Defines the viewable scene.
35 
36 #ifndef G4SCENE_HH
37 #define G4SCENE_HH
38 
39 #include "globals.hh"
40 #include "G4ios.hh"
41 
42 class G4VPhysicalVolume;
43 
44 #include "G4VisExtent.hh"
45 #include "G4Point3D.hh"
46 #include "G4VModel.hh"
47 #include <vector>
48 
49 class G4Scene {
50 
51 public: // With description
52 
53  friend std::ostream& operator << (std::ostream& os, const G4Scene& d);
54 
55  enum {UNLIMITED = -1};
56 
57  G4Scene (const G4String& name = "scene-with-unspecified-name");
58  ~G4Scene ();
59 
60  // Makes use of default (compiler generated) copy constructor and
61  // assignment operator.
62 
63  G4bool operator == (const G4Scene&) const;
64  G4bool operator != (const G4Scene&) const;
65 
67  // Get functions...
68 
69  const G4String& GetName () const;
70 
71  G4bool IsEmpty () const;
72 
73  struct Model {
74  Model(G4VModel* pModel): fActive(true), fpModel(pModel) {}
77  };
78 
79  const std::vector<Model>& GetRunDurationModelList () const;
80  // Contains models which are expected to last for the duration of
81  // the run, for example geometry volumes.
82 
83  const std::vector<Model>& GetEndOfEventModelList () const;
84  // Contains models which are described at the end of event when the
85  // scene is current.
86 
87  const std::vector<Model>& GetEndOfRunModelList () const;
88  // Contains models which are described at the end of event when the
89  // scene is current.
90 
91  const G4VisExtent& GetExtent () const;
92  // Overall extent of all objects in the scene.
93 
94  const G4Point3D& GetStandardTargetPoint () const;
95  // Usually centre of extent. See G4ViewParameters for definition.
96 
98  // If true, the visualization manager will request viewer to refresh
99  // "transient" objects, such as hits, at end of event. Otherwise
100  // they will be accumulated.
101 
103  // If RefreshAtEndOfEvent is false, events of the current run are
104  // kept up to this maximum number. A negative value means all
105  // events of current run are kept. The events are available for
106  // viewing at the end of run, but are deleted just before the start
107  // of the next run.
108 
109  G4bool GetRefreshAtEndOfRun () const;
110  // If true, the visualization manager will request viewer to refresh
111  // "transient" objects, such as hits, at end of run. Otherwise
112  // they will be accumulated.
113 
115  // Add and Set functions...
116 
117  G4bool AddRunDurationModel (G4VModel*, G4bool warn = false);
118  // Adds models of type which are expected to last for the duration
119  // of the run, for example geometry volumes.
120  // Returns false if model is already in the list.
121  // Prints warnings if warn is true.
122 
123  G4bool AddWorldIfEmpty (G4bool warn = false);
124  // In some situations, if the user asks for a drawing and has not
125  // yet set any run duration models it makes sense to put the "world"
126  // in there by default.
127  // Returns false if model is already in the list.
128  // Prints warnings if warn is true.
129 
130  G4bool AddEndOfEventModel (G4VModel*, G4bool warn = false);
131  // Adds models of type which are described at the end of event when
132  // the scene is current.
133  // Returns false if model is already in the list.
134  // Prints warnings if warn is true.
135 
136  G4bool AddEndOfRunModel (G4VModel*, G4bool warn = false);
137  // Adds models of type which are described at the end of run when
138  // the scene is current.
139  // Returns false if model is already in the list.
140  // Prints warnings if warn is true.
141 
142  void SetName (const G4String&);
143  // Use with care. User normally sets scene name by vis commands.
144 
145  std::vector<Model>& SetRunDurationModelList ();
146  // Allows you to change the model list - do with care!
147 
148  std::vector<Model>& SetEndOfEventModelList ();
149  // Allows you to change the model list - do with care!
150 
151  std::vector<Model>& SetEndOfRunModelList ();
152  // Allows you to change the model list - do with care!
153 
155  // If set true, the visualization manager will request viewer to
156  // refresh "transient" objects, such as hits, at end of event.
157  // Otherwise they will be accumulated.
158 
160  // If RefreshAtEndOfEvent is false, events of the current run are
161  // kept up to this maximum number. A negative value means all
162  // events of current run are kept. The events are available for
163  // viewing at the end of run, but are deleted just before the start
164  // of the next run.
165 
167  // If set true, the visualization manager will request viewer to
168  // refresh "transient" objects, such as hits, at end of run.
169  // Otherwise they will be accumulated.
170 
172  // Other functions...
173 
174  void CalculateExtent();
175  // (Re-)calculates the extent from the extents of its models.
176 
177 private:
179  std::vector<Model> fRunDurationModelList;
180  std::vector<Model> fEndOfEventModelList;
181  std::vector<Model> fEndOfRunModelList;
187 };
188 
189 #include "G4Scene.icc"
190 
191 #endif
G4String fName
Definition: G4Scene.hh:178
std::vector< Model > fEndOfRunModelList
Definition: G4Scene.hh:181
Model(G4VModel *pModel)
Definition: G4Scene.hh:74
~G4Scene()
Definition: G4Scene.cc:47
const std::vector< Model > & GetEndOfEventModelList() const
G4Scene(const G4String &name="scene-with-unspecified-name")
Definition: G4Scene.cc:40
G4VModel * fpModel
Definition: G4Scene.hh:76
void SetName(const G4String &)
G4bool operator!=(const G4Scene &) const
Definition: G4Scene.cc:280
G4String name
Definition: TRTMaterials.hh:40
G4bool fRefreshAtEndOfRun
Definition: G4Scene.hh:185
friend std::ostream & operator<<(std::ostream &os, const G4Scene &d)
Definition: G4Scene.cc:232
HepGeom::Point3D< G4double > G4Point3D
Definition: G4Point3D.hh:35
std::vector< Model > fEndOfEventModelList
Definition: G4Scene.hh:180
std::vector< Model > & SetEndOfRunModelList()
G4bool IsEmpty() const
G4bool GetRefreshAtEndOfEvent() const
const G4String & GetName() const
int G4int
Definition: G4Types.hh:78
G4Point3D fStandardTargetPoint
Definition: G4Scene.hh:183
G4bool fActive
Definition: G4Scene.hh:75
G4VisExtent fExtent
Definition: G4Scene.hh:182
const G4VisExtent & GetExtent() const
const G4Point3D & GetStandardTargetPoint() const
G4bool AddRunDurationModel(G4VModel *, G4bool warn=false)
Definition: G4Scene.cc:49
G4bool operator==(const G4Scene &) const
bool G4bool
Definition: G4Types.hh:79
void SetMaxNumberOfKeptEvents(G4int)
const std::vector< Model > & GetRunDurationModelList() const
G4bool GetRefreshAtEndOfRun() const
const std::vector< Model > & GetEndOfRunModelList() const
void CalculateExtent()
Definition: G4Scene.cc:72
G4bool AddEndOfRunModel(G4VModel *, G4bool warn=false)
Definition: G4Scene.cc:212
G4bool AddWorldIfEmpty(G4bool warn=false)
Definition: G4Scene.cc:156
std::vector< Model > & SetRunDurationModelList()
std::vector< Model > & SetEndOfEventModelList()
G4bool AddEndOfEventModel(G4VModel *, G4bool warn=false)
Definition: G4Scene.cc:192
G4bool fRefreshAtEndOfEvent
Definition: G4Scene.hh:184
void SetRefreshAtEndOfRun(G4bool)
G4int GetMaxNumberOfKeptEvents() const
G4int fMaxNumberOfKeptEvents
Definition: G4Scene.hh:186
void SetRefreshAtEndOfEvent(G4bool)
std::vector< Model > fRunDurationModelList
Definition: G4Scene.hh:179