Geant4-11
Data Structures | Public Types | Public Member Functions | Private Attributes | Friends
G4Scene Class Reference

#include <G4Scene.hh>

Data Structures

struct  Model
 

Public Types

enum  { UNLIMITED = -1 }
 

Public Member Functions

G4bool AddEndOfEventModel (G4VModel *, G4bool warn=false)
 
G4bool AddEndOfRunModel (G4VModel *, G4bool warn=false)
 
G4bool AddRunDurationModel (G4VModel *, G4bool warn=false)
 
G4bool AddWorldIfEmpty (G4bool warn=false)
 
void CalculateExtent ()
 
 G4Scene (const G4String &name="scene-with-unspecified-name")
 
const std::vector< Model > & GetEndOfEventModelList () const
 
const std::vector< Model > & GetEndOfRunModelList () const
 
const G4VisExtentGetExtent () const
 
G4int GetMaxNumberOfKeptEvents () const
 
const G4StringGetName () const
 
G4bool GetRefreshAtEndOfEvent () const
 
G4bool GetRefreshAtEndOfRun () const
 
const std::vector< Model > & GetRunDurationModelList () const
 
const G4Point3DGetStandardTargetPoint () const
 
G4bool IsEmpty () const
 
G4bool operator!= (const G4Scene &) const
 
G4bool operator== (const G4Scene &) const
 
std::vector< Model > & SetEndOfEventModelList ()
 
std::vector< Model > & SetEndOfRunModelList ()
 
void SetMaxNumberOfKeptEvents (G4int)
 
void SetName (const G4String &)
 
void SetRefreshAtEndOfEvent (G4bool)
 
void SetRefreshAtEndOfRun (G4bool)
 
std::vector< Model > & SetRunDurationModelList ()
 
 ~G4Scene ()
 

Private Attributes

std::vector< ModelfEndOfEventModelList
 
std::vector< ModelfEndOfRunModelList
 
G4VisExtent fExtent
 
G4int fMaxNumberOfKeptEvents
 
G4String fName
 
G4bool fRefreshAtEndOfEvent
 
G4bool fRefreshAtEndOfRun
 
std::vector< ModelfRunDurationModelList
 
G4Point3D fStandardTargetPoint
 

Friends

std::ostream & operator<< (std::ostream &os, const G4Scene &d)
 

Detailed Description

Definition at line 48 of file G4Scene.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
UNLIMITED 

Definition at line 54 of file G4Scene.hh.

54{UNLIMITED = -1};
@ UNLIMITED
Definition: G4Scene.hh:54

Constructor & Destructor Documentation

◆ G4Scene()

G4Scene::G4Scene ( const G4String name = "scene-with-unspecified-name")

Definition at line 41 of file G4Scene.cc.

41 :
42 fName (name),
46{} // Note all other data members have default initial values.
G4int fMaxNumberOfKeptEvents
Definition: G4Scene.hh:185
G4bool fRefreshAtEndOfRun
Definition: G4Scene.hh:184
G4String fName
Definition: G4Scene.hh:177
G4bool fRefreshAtEndOfEvent
Definition: G4Scene.hh:183
const char * name(G4int ptype)

◆ ~G4Scene()

G4Scene::~G4Scene ( )

Definition at line 48 of file G4Scene.cc.

48{}

Member Function Documentation

◆ AddEndOfEventModel()

G4bool G4Scene::AddEndOfEventModel ( G4VModel pModel,
G4bool  warn = false 
)

Definition at line 182 of file G4Scene.cc.

182 {
183 G4int i, nModels = fEndOfEventModelList.size ();
184 for (i = 0; i < nModels; i++) {
185 if (pModel -> GetGlobalDescription () ==
186 fEndOfEventModelList[i].fpModel -> GetGlobalDescription ()) break;
187 }
188 if (i < nModels) {
189 if (warn) {
190 G4cout << "G4Scene::AddEndOfEventModel: a model \""
191 << pModel -> GetGlobalDescription ()
192 << "\"\n is already in the end-of-event list of scene \""
193 << fName << "\"."
194 << G4endl;
195 }
196 return false;
197 }
198 fEndOfEventModelList.push_back (Model(pModel));
199 return true;
200}
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
std::vector< Model > fEndOfEventModelList
Definition: G4Scene.hh:179

References fEndOfEventModelList, fName, G4cout, and G4endl.

◆ AddEndOfRunModel()

G4bool G4Scene::AddEndOfRunModel ( G4VModel pModel,
G4bool  warn = false 
)

Definition at line 202 of file G4Scene.cc.

202 {
203 G4int i, nModels = fEndOfRunModelList.size ();
204 for (i = 0; i < nModels; i++) {
205 if (pModel -> GetGlobalDescription () ==
206 fEndOfRunModelList[i].fpModel -> GetGlobalDescription ()) break;
207 }
208 if (i < nModels) {
209 if (warn) {
210 G4cout << "G4Scene::AddEndOfRunModel: a model \""
211 << pModel -> GetGlobalDescription ()
212 << "\"\n is already in the end-of-run list of scene \""
213 << fName << "\"."
214 << G4endl;
215 }
216 return false;
217 }
218 fEndOfRunModelList.push_back (pModel);
219 return true;
220}
std::vector< Model > fEndOfRunModelList
Definition: G4Scene.hh:180

References fEndOfRunModelList, fName, G4cout, and G4endl.

◆ AddRunDurationModel()

G4bool G4Scene::AddRunDurationModel ( G4VModel pModel,
G4bool  warn = false 
)

Definition at line 158 of file G4Scene.cc.

159{
160 std::vector<Model>::const_iterator i;
161 for (i = fRunDurationModelList.begin ();
162 i != fRunDurationModelList.end (); ++i) {
163 if (pModel -> GetGlobalDescription () ==
164 i->fpModel->GetGlobalDescription ()) break;
165 }
166 if (i != fRunDurationModelList.end ()) {
167 if (warn) {
168 G4cout << "G4Scene::AddRunDurationModel: model \""
169 << pModel -> GetGlobalDescription ()
170 << "\"\n is already in the run-duration list of scene \""
171 << fName
172 << "\"."
173 << G4endl;
174 }
175 return false;
176 }
177 fRunDurationModelList.push_back (Model(pModel));
179 return true;
180}
void CalculateExtent()
Definition: G4Scene.cc:62
std::vector< Model > fRunDurationModelList
Definition: G4Scene.hh:178

References CalculateExtent(), fName, fRunDurationModelList, G4cout, G4endl, and G4VModel::GetGlobalDescription().

Referenced by AddWorldIfEmpty(), G4VisCommandSceneAddLocalAxes::SetNewValue(), G4VisCommandSceneAddVolume::SetNewValue(), G4VisCommandsTouchable::SetNewValue(), and G4VisCommandViewerCentreOn::SetNewValue().

◆ AddWorldIfEmpty()

G4bool G4Scene::AddWorldIfEmpty ( G4bool  warn = false)

Definition at line 122 of file G4Scene.cc.

122 {
123 G4bool successful = true;
124 if (IsEmpty ()) {
125 successful = false;
126 G4VPhysicalVolume* pWorld =
128 -> GetNavigatorForTracking () -> GetWorldVolume ();
129 if (pWorld) {
130 const G4VisAttributes* pVisAttribs =
131 pWorld -> GetLogicalVolume () -> GetVisAttributes ();
132 if (!pVisAttribs || pVisAttribs -> IsVisible ()) {
133 if (warn) {
134 G4cout <<
135 "Your \"world\" has no vis attributes or is marked as visible."
136 "\n For a better view of the contents, mark the world as"
137 " invisible, e.g.,"
138 "\n myWorldLogicalVol ->"
139 " SetVisAttributes (G4VisAttributes::GetInvisible());"
140 << G4endl;
141 }
142 }
143 successful = AddRunDurationModel (new G4PhysicalVolumeModel (pWorld));
144 // Note: default depth and no modeling parameters.
145 if (successful) {
146 if (warn) {
147 G4cout <<
148 "G4Scene::AddWorldIfEmpty: The scene was empty of run-duration models."
149 "\n \"world\" has been added.";
150 G4cout << G4endl;
151 }
152 }
153 }
154 }
155 return successful;
156}
bool G4bool
Definition: G4Types.hh:86
G4bool AddRunDurationModel(G4VModel *, G4bool warn=false)
Definition: G4Scene.cc:158
G4bool IsEmpty() const
static G4TransportationManager * GetTransportationManager()

References AddRunDurationModel(), G4cout, G4endl, G4TransportationManager::GetTransportationManager(), and IsEmpty().

Referenced by G4RayTracerSceneHandler::G4RayTracerSceneHandler().

◆ CalculateExtent()

void G4Scene::CalculateExtent ( )

Definition at line 62 of file G4Scene.cc.

63{
64 G4BoundingExtentScene boundingExtentScene;
65
66 for (size_t i = 0; i < fRunDurationModelList.size(); i++) {
67 if (fRunDurationModelList[i].fActive) {
68 G4VModel* model = fRunDurationModelList[i].fpModel;
69 if (model -> Validate()) {
70 const G4VisExtent& thisExtent = model -> GetExtent ();
71 if (thisExtent != G4VisExtent::GetNullExtent()) {
72 boundingExtentScene.AccrueBoundingExtent(thisExtent);
73 }
74 } else {
75 PrintInvalidModel(model);
76 }
77 }
78 }
79
80 for (size_t i = 0; i < fEndOfEventModelList.size(); i++) {
81 if (fEndOfEventModelList[i].fActive) {
82 G4VModel* model = fEndOfEventModelList[i].fpModel;
83 if (model -> Validate()) {
84 const G4VisExtent& thisExtent = model -> GetExtent ();
85 if (thisExtent != G4VisExtent::GetNullExtent()) {
86 boundingExtentScene.AccrueBoundingExtent(thisExtent);
87 }
88 } else {
89 PrintInvalidModel(model);
90 }
91 }
92 }
93
94 for (size_t i = 0; i < fEndOfRunModelList.size(); i++) {
95 if (fEndOfRunModelList[i].fActive) {
96 G4VModel* model = fEndOfRunModelList[i].fpModel;
97 if (model -> Validate()) {
98 const G4VisExtent& thisExtent = model -> GetExtent ();
99 if (thisExtent != G4VisExtent::GetNullExtent()) {
100 boundingExtentScene.AccrueBoundingExtent(thisExtent);
101 }
102 } else {
103 PrintInvalidModel(model);
104 }
105 }
106 }
107
108 fExtent = boundingExtentScene.GetBoundingExtent ();
110 if (fExtent.GetExtentRadius() <= 0.) {
112 ("G4Scene::CalculateExtent",
113 "visman0202", JustWarning,
114 "Scene has no extent. Please activate or add something."
115 "\nThe camera needs to have something to point at!"
116 "\nAdd a volume. (You may need \"/run/initialize\".)"
117 "\nOr use \"/vis/scene/add/extent\"."
118 "\n\"/vis/scene/list\" to see list of models.");
119 }
120}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
void AccrueBoundingExtent(const G4VisExtent &)
const G4VisExtent & GetBoundingExtent() const
const G4VisExtent & GetExtent() const
G4Point3D fStandardTargetPoint
Definition: G4Scene.hh:182
G4VisExtent fExtent
Definition: G4Scene.hh:181
static const G4VisExtent & GetNullExtent()
Definition: G4VisExtent.cc:60
G4double GetExtentRadius() const
Definition: G4VisExtent.cc:75
const G4Point3D & GetExtentCentre() const
Definition: G4VisExtent.cc:65
void PrintInvalidModel(const G4VModel *model)
Definition: G4Scene.cc:51

References G4BoundingExtentScene::AccrueBoundingExtent(), fEndOfEventModelList, fEndOfRunModelList, fExtent, fRunDurationModelList, fStandardTargetPoint, G4Exception(), G4BoundingExtentScene::GetBoundingExtent(), GetExtent(), G4VisExtent::GetExtentCentre(), G4VisExtent::GetExtentRadius(), G4VisExtent::GetNullExtent(), JustWarning, and anonymous_namespace{G4Scene.cc}::PrintInvalidModel().

Referenced by AddRunDurationModel(), G4VisManager::GeometryHasChanged(), G4VisManager::NotifyHandlers(), and G4VisCommandSceneNotifyHandlers::SetNewValue().

◆ GetEndOfEventModelList()

const std::vector< Model > & G4Scene::GetEndOfEventModelList ( ) const

◆ GetEndOfRunModelList()

const std::vector< Model > & G4Scene::GetEndOfRunModelList ( ) const

◆ GetExtent()

const G4VisExtent & G4Scene::GetExtent ( ) const

◆ GetMaxNumberOfKeptEvents()

G4int G4Scene::GetMaxNumberOfKeptEvents ( ) const

◆ GetName()

const G4String & G4Scene::GetName ( ) const

◆ GetRefreshAtEndOfEvent()

G4bool G4Scene::GetRefreshAtEndOfEvent ( ) const

◆ GetRefreshAtEndOfRun()

G4bool G4Scene::GetRefreshAtEndOfRun ( ) const

◆ GetRunDurationModelList()

const std::vector< Model > & G4Scene::GetRunDurationModelList ( ) const

◆ GetStandardTargetPoint()

const G4Point3D & G4Scene::GetStandardTargetPoint ( ) const

◆ IsEmpty()

G4bool G4Scene::IsEmpty ( ) const

Referenced by AddWorldIfEmpty().

◆ operator!=()

G4bool G4Scene::operator!= ( const G4Scene scene) const

Definition at line 279 of file G4Scene.cc.

279 {
280 if (
281 (fRunDurationModelList.size () !=
282 scene.fRunDurationModelList.size ()) ||
283 (fEndOfEventModelList.size () !=
284 scene.fEndOfEventModelList.size ()) ||
285 (fEndOfRunModelList.size () !=
286 scene.fEndOfRunModelList.size ()) ||
287 (fExtent != scene.fExtent) ||
292 ) return true;
293
294 /* A complete comparison should, perhaps, include a comparison of
295 individual models, but it is not easy to implement operator!= for
296 all models. Also, it would be unfeasible to ask users to
297 implement opeerator!= if we ever get round to allowing
298 user-defined models. Moreover, there is no editing of G4Scene
299 objects, apart from changing fRefreshAtEndOfEvent, etc; as far as
300 models are concerned, all you can ever do is add them, so a test
301 on size (above) is enough.
302
303 for (size_t i = 0; i < fRunDurationModelList.size (); i++) {
304 if (fRunDurationModelList[i] != scene.fRunDurationModelList[i])
305 return true;
306 }
307
308 for (size_t i = 0; i < fEndOfEventModelList.size (); i++) {
309 if (fEndOfEventModelList[i] != scene.fEndOfEventModelList[i])
310 return true;
311 }
312
313 for (size_t i = 0; i < fEndOfRunModelList.size (); i++) {
314 if (fEndOfRunModelList[i] != scene.fEndOfRunModelList[i])
315 return true;
316 }
317 */
318
319 return false;
320}

References fEndOfEventModelList, fEndOfRunModelList, fExtent, fMaxNumberOfKeptEvents, fRefreshAtEndOfEvent, fRefreshAtEndOfRun, fRunDurationModelList, and fStandardTargetPoint.

◆ operator==()

G4bool G4Scene::operator== ( const G4Scene ) const

◆ SetEndOfEventModelList()

std::vector< Model > & G4Scene::SetEndOfEventModelList ( )

◆ SetEndOfRunModelList()

std::vector< Model > & G4Scene::SetEndOfRunModelList ( )

◆ SetMaxNumberOfKeptEvents()

void G4Scene::SetMaxNumberOfKeptEvents ( G4int  )

◆ SetName()

void G4Scene::SetName ( const G4String )

◆ SetRefreshAtEndOfEvent()

void G4Scene::SetRefreshAtEndOfEvent ( G4bool  )

◆ SetRefreshAtEndOfRun()

void G4Scene::SetRefreshAtEndOfRun ( G4bool  )

◆ SetRunDurationModelList()

std::vector< Model > & G4Scene::SetRunDurationModelList ( )

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const G4Scene d 
)
friend

Definition at line 222 of file G4Scene.cc.

222 {
223
224 size_t i;
225
226 os << "Scene data:";
227
228 os << "\n Run-duration model list:";
229 if (scene.fRunDurationModelList.size () == 0) {
230 os << " none";
231 }
232 for (i = 0; i < scene.fRunDurationModelList.size (); i++) {
233 if (scene.fRunDurationModelList[i].fActive) os << "\n Active: ";
234 else os << "\n Inactive: ";
235 os << *(scene.fRunDurationModelList[i].fpModel);
236 }
237
238 os << "\n End-of-event model list:";
239 if (scene.fEndOfEventModelList.size () == 0) {
240 os << " none";
241 }
242 for (i = 0; i < scene.fEndOfEventModelList.size (); i++) {
243 if (scene.fEndOfEventModelList[i].fActive) os << "\n Active: ";
244 else os << "\n Inactive: ";
245 os << *(scene.fEndOfEventModelList[i].fpModel);
246 }
247
248 os << "\n End-of-run model list:";
249 if (scene.fEndOfRunModelList.size () == 0) {
250 os << " none";
251 }
252 for (i = 0; i < scene.fEndOfRunModelList.size (); i++) {
253 if (scene.fEndOfRunModelList[i].fActive) os << "\n Active: ";
254 else os << "\n Inactive: ";
255 os << *(scene.fEndOfRunModelList[i].fpModel);
256 }
257
258 os << "\n Overall extent or bounding box: " << scene.fExtent;
259
260 os << "\n Standard target point: " << scene.fStandardTargetPoint;
261
262 os << "\n End of event action set to \"";
263 if (scene.fRefreshAtEndOfEvent) os << "refresh\"";
264 else {
265 os << "accumulate (maximum number of kept events: ";
266 if (scene.fMaxNumberOfKeptEvents >= 0) os << scene.fMaxNumberOfKeptEvents;
267 else os << "unlimited";
268 os << ")";
269 }
270
271 os << "\n End of run action set to \"";
272 if (scene.fRefreshAtEndOfRun) os << "refresh";
273 else os << "accumulate";
274 os << "\"";
275
276 return os;
277}

Field Documentation

◆ fEndOfEventModelList

std::vector<Model> G4Scene::fEndOfEventModelList
private

Definition at line 179 of file G4Scene.hh.

Referenced by AddEndOfEventModel(), CalculateExtent(), and operator!=().

◆ fEndOfRunModelList

std::vector<Model> G4Scene::fEndOfRunModelList
private

Definition at line 180 of file G4Scene.hh.

Referenced by AddEndOfRunModel(), CalculateExtent(), and operator!=().

◆ fExtent

G4VisExtent G4Scene::fExtent
private

Definition at line 181 of file G4Scene.hh.

Referenced by CalculateExtent(), and operator!=().

◆ fMaxNumberOfKeptEvents

G4int G4Scene::fMaxNumberOfKeptEvents
private

Definition at line 185 of file G4Scene.hh.

Referenced by operator!=().

◆ fName

G4String G4Scene::fName
private

Definition at line 177 of file G4Scene.hh.

Referenced by AddEndOfEventModel(), AddEndOfRunModel(), and AddRunDurationModel().

◆ fRefreshAtEndOfEvent

G4bool G4Scene::fRefreshAtEndOfEvent
private

Definition at line 183 of file G4Scene.hh.

Referenced by operator!=().

◆ fRefreshAtEndOfRun

G4bool G4Scene::fRefreshAtEndOfRun
private

Definition at line 184 of file G4Scene.hh.

Referenced by operator!=().

◆ fRunDurationModelList

std::vector<Model> G4Scene::fRunDurationModelList
private

Definition at line 178 of file G4Scene.hh.

Referenced by AddRunDurationModel(), CalculateExtent(), and operator!=().

◆ fStandardTargetPoint

G4Point3D G4Scene::fStandardTargetPoint
private

Definition at line 182 of file G4Scene.hh.

Referenced by CalculateExtent(), and operator!=().


The documentation for this class was generated from the following files: