G4Scene Class Reference

#include <G4Scene.hh>


Public Types

 UNLIMITED = -1
enum  { UNLIMITED = -1 }

Public Member Functions

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

Friends

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

Data Structures

struct  Model


Detailed Description

Definition at line 49 of file G4Scene.hh.


Member Enumeration Documentation

anonymous enum

Enumerator:
UNLIMITED 

Definition at line 55 of file G4Scene.hh.

00055 {UNLIMITED = -1};


Constructor & Destructor Documentation

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

Definition at line 40 of file G4Scene.cc.

00040                                      :
00041   fName (name),
00042   fRefreshAtEndOfEvent(true),
00043   fRefreshAtEndOfRun(true),
00044   fMaxNumberOfKeptEvents(0)
00045 {} // Note all other data members have default initial values.

G4Scene::~G4Scene (  ) 

Definition at line 47 of file G4Scene.cc.

00047 {}


Member Function Documentation

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

Definition at line 190 of file G4Scene.cc.

References G4cout, and G4endl.

00190                                                                  {
00191   G4int i, nModels = fEndOfEventModelList.size ();
00192   for (i = 0; i < nModels; i++) {
00193     if (pModel -> GetGlobalDescription () ==
00194         fEndOfEventModelList[i].fpModel -> GetGlobalDescription ()) break;
00195   }
00196   if (i < nModels) {
00197     if (warn) {
00198       G4cout << "G4Scene::AddEndOfEventModel: a model \""
00199              << pModel -> GetGlobalDescription ()
00200              << "\"\n  is already in the end-of-event list of scene \""
00201              << fName << "\"."
00202              << G4endl;
00203     }
00204     return false;
00205   }
00206   fEndOfEventModelList.push_back (Model(pModel));
00207   return true;
00208 }

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

Definition at line 210 of file G4Scene.cc.

References G4cout, and G4endl.

00210                                                                {
00211   G4int i, nModels = fEndOfRunModelList.size ();
00212   for (i = 0; i < nModels; i++) {
00213     if (pModel -> GetGlobalDescription () ==
00214         fEndOfRunModelList[i].fpModel -> GetGlobalDescription ()) break;
00215   }
00216   if (i < nModels) {
00217     if (warn) {
00218       G4cout << "G4Scene::AddEndOfRunModel: a model \""
00219              << pModel -> GetGlobalDescription ()
00220              << "\"\n  is already in the end-of-run list of scene \""
00221              << fName << "\"."
00222              << G4endl;
00223     }
00224     return false;
00225   }
00226   fEndOfRunModelList.push_back (pModel);
00227   return true;
00228 }

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

Definition at line 49 of file G4Scene.cc.

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

Referenced by AddWorldIfEmpty().

00049                                                                   {
00050   std::vector<Model>::const_iterator i;
00051   for (i = fRunDurationModelList.begin ();
00052        i != fRunDurationModelList.end (); ++i) {
00053     if (pModel -> GetGlobalDescription () ==
00054         i->fpModel->GetGlobalDescription ()) break;
00055   }
00056   if (i != fRunDurationModelList.end ()) {
00057     if (warn) {
00058       G4cout << "G4Scene::AddRunDurationModel: model \""
00059              << pModel -> GetGlobalDescription ()
00060              << "\"\n  is already in the run-duration list of scene \""
00061              << fName
00062              << "\"."
00063              << G4endl;
00064     }
00065     return false;
00066   }
00067   fRunDurationModelList.push_back (Model(pModel));
00068   CalculateExtent ();
00069   return true;
00070 }

G4bool G4Scene::AddWorldIfEmpty ( G4bool  warn = false  ) 

Definition at line 154 of file G4Scene.cc.

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

Referenced by G4RayTracerSceneHandler::G4RayTracerSceneHandler().

00154                                             {
00155   G4bool successful = true;
00156   if (IsEmpty ()) {
00157     successful = false;
00158     G4VPhysicalVolume* pWorld =
00159       G4TransportationManager::GetTransportationManager ()
00160       -> GetNavigatorForTracking () -> GetWorldVolume ();
00161     if (pWorld) {
00162       const G4VisAttributes* pVisAttribs =
00163         pWorld -> GetLogicalVolume () -> GetVisAttributes ();
00164       if (!pVisAttribs || pVisAttribs -> IsVisible ()) {
00165         if (warn) {
00166           G4cout << 
00167             "Your \"world\" has no vis attributes or is marked as visible."
00168             "\n  For a better view of the contents, mark the world as"
00169             " invisible, e.g.,"
00170             "\n  myWorldLogicalVol ->"
00171             " SetVisAttributes (G4VisAttributes::Invisible);"
00172                  << G4endl;
00173         }
00174       }
00175       successful = AddRunDurationModel (new G4PhysicalVolumeModel (pWorld));
00176       // Note: default depth and no modeling parameters.
00177       if (successful) {
00178         if (warn) {
00179           G4cout <<
00180     "G4Scene::AddWorldIfEmpty: The scene was empty of run-duration models."
00181     "\n  \"world\" has been added.";
00182           G4cout << G4endl;
00183         }
00184       }
00185     }
00186   }
00187   return successful;
00188 }

void G4Scene::CalculateExtent (  ) 

Definition at line 72 of file G4Scene.cc.

References G4BoundingSphereScene::AccrueBoundingSphere(), G4Exception(), G4BoundingSphereScene::GetBoundingSphereExtent(), GetExtent(), G4VisExtent::GetExtentCentre(), G4VisExtent::GetExtentRadius(), G4VModel::GetGlobalDescription(), and JustWarning.

Referenced by AddRunDurationModel(), and G4VisCommandSceneNotifyHandlers::SetNewValue().

00073 {
00074   G4BoundingSphereScene boundingSphereScene;
00075 
00076   for (size_t i = 0; i < fRunDurationModelList.size(); i++) {
00077     if (fRunDurationModelList[i].fActive) {
00078       G4VModel* model = fRunDurationModelList[i].fpModel;
00079       if (model -> Validate()) {  // Validates and also recomputes extent.
00080         const G4VisExtent& thisExtent = model -> GetExtent ();
00081         G4double thisRadius = thisExtent.GetExtentRadius ();
00082         if (thisRadius > 0.) {
00083           G4Point3D thisCentre = thisExtent.GetExtentCentre ();
00084           thisCentre.transform (model -> GetTransformation ());
00085           boundingSphereScene.AccrueBoundingSphere (thisCentre, thisRadius);
00086         }
00087       } else {
00088         G4ExceptionDescription ed;
00089         ed << "Invalid model \"" << model->GetGlobalDescription()
00090            << "\".\n  Not included in extent calculation.";
00091         G4Exception
00092           ("G4Scene::CalculateExtent",
00093            "visman0201", JustWarning, ed);
00094       }
00095     }
00096   }
00097 
00098   for (size_t i = 0; i < fEndOfEventModelList.size(); i++) {
00099     if (fEndOfEventModelList[i].fActive) {
00100       G4VModel* model = fEndOfEventModelList[i].fpModel;
00101       if (model -> Validate()) {  // Validates and also recomputes extent.
00102         const G4VisExtent& thisExtent = model -> GetExtent ();
00103         G4double thisRadius = thisExtent.GetExtentRadius ();
00104         if (thisRadius > 0.) {
00105           G4Point3D thisCentre = thisExtent.GetExtentCentre ();
00106           thisCentre.transform (model -> GetTransformation ());
00107           boundingSphereScene.AccrueBoundingSphere (thisCentre, thisRadius);
00108         }
00109       } else {
00110         G4ExceptionDescription ed;
00111         ed << "Invalid model \"" << model->GetGlobalDescription()
00112            << "\".\n  Not included in extent calculation.";
00113         G4Exception
00114           ("G4Scene::CalculateExtent",
00115            "visman0201", JustWarning, ed);
00116       }
00117     }
00118   }
00119 
00120   for (size_t i = 0; i < fEndOfRunModelList.size(); i++) {
00121     if (fEndOfRunModelList[i].fActive) {
00122       G4VModel* model = fEndOfRunModelList[i].fpModel;
00123       if (model -> Validate()) {  // Validates and also recomputes extent.
00124         const G4VisExtent& thisExtent = model -> GetExtent ();
00125         G4double thisRadius = thisExtent.GetExtentRadius ();
00126         if (thisRadius > 0.) {
00127           G4Point3D thisCentre = thisExtent.GetExtentCentre ();
00128           thisCentre.transform (model -> GetTransformation ());
00129           boundingSphereScene.AccrueBoundingSphere (thisCentre, thisRadius);
00130         }
00131       } else {
00132         G4ExceptionDescription ed;
00133         ed << "Invalid model \"" << model->GetGlobalDescription()
00134            << "\".\n  Not included in extent calculation.";
00135         G4Exception
00136           ("G4Scene::CalculateExtent",
00137            "visman0201", JustWarning, ed);
00138       }
00139     }
00140   }
00141 
00142   fExtent = boundingSphereScene.GetBoundingSphereExtent ();
00143   fStandardTargetPoint = fExtent.GetExtentCentre ();
00144   if (fExtent.GetExtentRadius() <= 0.) {
00145         G4Exception
00146           ("G4Scene::CalculateExtent",
00147            "visman0202", JustWarning,
00148            "Scene has no extent.  Please activate or add something."
00149            "\nThe camera needs to have something to point at!"
00150            "\n\"/vis/scene/list\" to see list of models.");
00151   }
00152 }

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

Definition at line 50 of file G4Scene.icc.

Referenced by G4GMocrenFileSceneHandler::GFBeginModeling().

00050                                        {
00051   return fEndOfEventModelList;
00052 }

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

Definition at line 55 of file G4Scene.icc.

00055                                      {
00056   return fEndOfRunModelList;
00057 }

const G4VisExtent & G4Scene::GetExtent (  )  const [inline]

Definition at line 59 of file G4Scene.icc.

Referenced by G4VSceneHandler::AddPrimitive(), CalculateExtent(), G4VSceneHandler::CreateSectionSolid(), G4DAWNFILEViewer::SendViewParameters(), G4VisCommandSceneAddScale::SetNewValue(), G4VisCommandSceneAddLogo::SetNewValue(), G4VisCommandSceneAddAxes::SetNewValue(), G4VisCommandSceneAddArrow::SetNewValue(), and G4RayTracerViewer::SetView().

00059                                                     {
00060   return fExtent;
00061 }

G4int G4Scene::GetMaxNumberOfKeptEvents (  )  const [inline]

Definition at line 71 of file G4Scene.icc.

00071                                                      {
00072   return fMaxNumberOfKeptEvents;
00073 }

const G4String & G4Scene::GetName (  )  const [inline]

Definition at line 36 of file G4Scene.icc.

Referenced by G4VisCommandViewerRefresh::SetNewValue(), and G4VisCommandSceneList::SetNewValue().

00036                                                {
00037   return fName;
00038 }

G4bool G4Scene::GetRefreshAtEndOfEvent (  )  const [inline]

Definition at line 67 of file G4Scene.icc.

Referenced by G4VSceneHandler::ProcessScene(), G4VisCommandSceneEndOfRunAction::SetNewValue(), G4VisCommandSceneEndOfEventAction::SetNewValue(), and G4VisCommandReviewKeptEvents::SetNewValue().

00067                                                      {
00068   return fRefreshAtEndOfEvent;
00069 }

G4bool G4Scene::GetRefreshAtEndOfRun (  )  const [inline]

Definition at line 75 of file G4Scene.icc.

Referenced by G4VSceneHandler::ProcessScene(), G4VisCommandSceneEndOfRunAction::SetNewValue(), and G4VisCommandSceneEndOfEventAction::SetNewValue().

00075                                                    {
00076   return fRefreshAtEndOfRun;
00077 }

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

Definition at line 45 of file G4Scene.icc.

Referenced by G4ASCIITreeSceneHandler::EndModeling(), and G4VisCommandViewerRefresh::SetNewValue().

00045                                         {
00046   return fRunDurationModelList;
00047 }

const G4Point3D & G4Scene::GetStandardTargetPoint (  )  const [inline]

Definition at line 63 of file G4Scene.icc.

Referenced by G4DAWNFILEViewer::SendViewParameters(), G4VisCommandsViewerSet::SetNewValue(), G4VisCommandViewerSave::SetNewValue(), and G4RayTracerViewer::SetView().

00063                                                                {
00064   return fStandardTargetPoint;
00065 }

G4bool G4Scene::IsEmpty (  )  const [inline]

Definition at line 40 of file G4Scene.icc.

Referenced by AddWorldIfEmpty().

00040                                       {
00041   return fRunDurationModelList.size () == 0;
00042 }

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

Definition at line 278 of file G4Scene.cc.

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

Referenced by operator==().

00278                                                        {
00279   if (
00280       (fRunDurationModelList.size () !=
00281        scene.fRunDurationModelList.size ())                 ||
00282       (fEndOfEventModelList.size () !=
00283        scene.fEndOfEventModelList.size ())                  ||
00284       (fEndOfRunModelList.size () !=
00285        scene.fEndOfRunModelList.size ())                    ||
00286       (fExtent               != scene.fExtent)              ||
00287       !(fStandardTargetPoint == scene.fStandardTargetPoint) ||
00288       fRefreshAtEndOfEvent   != scene.fRefreshAtEndOfEvent  ||
00289       fRefreshAtEndOfRun     != scene.fRefreshAtEndOfRun    ||
00290       fMaxNumberOfKeptEvents != scene.fMaxNumberOfKeptEvents
00291       ) return true;
00292 
00293   /* A complete comparison should, perhaps, include a comparison of
00294      individual models, but it is not easy to implement operator!= for
00295      all models.  Also, it would be unfeasible to ask users to
00296      implement opeerator!= if we ever get round to allowing
00297      user-defined models.  Moreover, there is no editing of G4Scene
00298      objects, apart from changing fRefreshAtEndOfEvent, etc; as far as
00299      models are concerned, all you can ever do is add them, so a test
00300      on size (above) is enough.
00301 
00302   for (size_t i = 0; i < fRunDurationModelList.size (); i++) {
00303     if (fRunDurationModelList[i] != scene.fRunDurationModelList[i])
00304       return true;
00305   }
00306 
00307   for (size_t i = 0; i < fEndOfEventModelList.size (); i++) {
00308     if (fEndOfEventModelList[i] != scene.fEndOfEventModelList[i])
00309       return true;
00310   }
00311 
00312   for (size_t i = 0; i < fEndOfRunModelList.size (); i++) {
00313     if (fEndOfRunModelList[i] != scene.fEndOfRunModelList[i])
00314       return true;
00315   }
00316   */
00317 
00318   return false;
00319 }

G4bool G4Scene::operator== ( const G4Scene  )  const [inline]

Definition at line 32 of file G4Scene.icc.

References operator!=().

00032                                                               {
00033   return !(G4Scene::operator != (scene));
00034 }

std::vector< G4Scene::Model > & G4Scene::SetEndOfEventModelList (  )  [inline]

Definition at line 88 of file G4Scene.icc.

Referenced by G4VisCommandSceneActivateModel::SetNewValue().

00089 {
00090   return fEndOfEventModelList;
00091 }

std::vector< G4Scene::Model > & G4Scene::SetEndOfRunModelList (  )  [inline]

Definition at line 93 of file G4Scene.icc.

Referenced by G4VisCommandSceneActivateModel::SetNewValue().

00094 {
00095   return fEndOfRunModelList;
00096 }

void G4Scene::SetMaxNumberOfKeptEvents ( G4int   )  [inline]

Definition at line 102 of file G4Scene.icc.

Referenced by G4VisCommandSceneEndOfEventAction::SetNewValue().

00102                                                        {
00103   fMaxNumberOfKeptEvents = max;
00104 }

void G4Scene::SetName ( const G4String  )  [inline]

Definition at line 79 of file G4Scene.icc.

00079                                                   {
00080   fName = name;
00081 }

void G4Scene::SetRefreshAtEndOfEvent ( G4bool   )  [inline]

Definition at line 98 of file G4Scene.icc.

Referenced by G4VisCommandSceneEndOfEventAction::SetNewValue(), and G4VisCommandReviewKeptEvents::SetNewValue().

00098                                                           {
00099   fRefreshAtEndOfEvent = refresh;
00100 }

void G4Scene::SetRefreshAtEndOfRun ( G4bool   )  [inline]

Definition at line 106 of file G4Scene.icc.

Referenced by G4VisCommandSceneEndOfRunAction::SetNewValue().

00106                                                         {
00107   fRefreshAtEndOfRun = refresh;
00108 }

std::vector< G4Scene::Model > & G4Scene::SetRunDurationModelList (  )  [inline]

Definition at line 83 of file G4Scene.icc.

Referenced by G4VisCommandSceneActivateModel::SetNewValue().

00084 {
00085   return fRunDurationModelList;
00086 }


Friends And Related Function Documentation

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

Definition at line 230 of file G4Scene.cc.

00230                                                                {
00231 
00232   size_t i;
00233 
00234   os << "Scene data:";
00235 
00236   os << "\n  Run-duration model list:";
00237   for (i = 0; i < scene.fRunDurationModelList.size (); i++) {
00238     if (scene.fRunDurationModelList[i].fActive) os << "\n  Active:   ";
00239     else os << "\n  Inactive: ";
00240     os << *(scene.fRunDurationModelList[i].fpModel);
00241   }
00242 
00243   os << "\n  End-of-event model list:";
00244   for (i = 0; i < scene.fEndOfEventModelList.size (); i++) {
00245     if (scene.fEndOfEventModelList[i].fActive) os << "\n  Active:   ";
00246     else os << "\n  Inactive: ";
00247     os << *(scene.fEndOfEventModelList[i].fpModel);
00248   }
00249 
00250   os << "\n  End-of-run model list:";
00251   for (i = 0; i < scene.fEndOfRunModelList.size (); i++) {
00252     if (scene.fEndOfRunModelList[i].fActive) os << "\n  Active:   ";
00253     else os << "\n  Inactive: ";
00254     os << *(scene.fEndOfRunModelList[i].fpModel);
00255   }
00256 
00257   os << "\n  Extent or bounding box: " << scene.fExtent;
00258 
00259   os << "\n  Standard target point:  " << scene.fStandardTargetPoint;
00260 
00261   os << "\n  End of event action set to \"";
00262   if (scene.fRefreshAtEndOfEvent) os << "refresh\"";
00263   else {
00264     os << "accumulate (maximum number of kept events: ";
00265     if (scene.fMaxNumberOfKeptEvents >= 0) os << scene.fMaxNumberOfKeptEvents;
00266     else os << "unlimited";
00267     os << ")";
00268   }
00269 
00270   os << "\n  End of run action set to \"";
00271   if (scene.fRefreshAtEndOfRun) os << "refresh";
00272   else os << "accumulate";
00273   os << "\"";
00274 
00275   return os;
00276 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:20 2013 for Geant4 by  doxygen 1.4.7