00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // 00030 // Scene John Allison 19th July 1996. 00031 // 00032 // Class Description: 00033 // 00034 // Defines the viewable scene. 00035 00036 #ifndef G4SCENE_HH 00037 #define G4SCENE_HH 00038 00039 #include "globals.hh" 00040 #include "G4ios.hh" 00041 00042 class G4VPhysicalVolume; 00043 00044 #include "G4VisExtent.hh" 00045 #include "G4Point3D.hh" 00046 #include "G4VModel.hh" 00047 #include <vector> 00048 00049 class G4Scene { 00050 00051 public: // With description 00052 00053 friend std::ostream& operator << (std::ostream& os, const G4Scene& d); 00054 00055 enum {UNLIMITED = -1}; 00056 00057 G4Scene (const G4String& name = "scene-with-unspecified-name"); 00058 ~G4Scene (); 00059 00060 // Makes use of default (compiler generated) copy constructor and 00061 // assignment operator. 00062 00063 G4bool operator == (const G4Scene&) const; 00064 G4bool operator != (const G4Scene&) const; 00065 00067 // Get functions... 00068 00069 const G4String& GetName () const; 00070 00071 G4bool IsEmpty () const; 00072 00073 struct Model { 00074 Model(G4VModel* pModel): fActive(true), fpModel(pModel) {} 00075 G4bool fActive; 00076 G4VModel* fpModel; 00077 }; 00078 00079 const std::vector<Model>& GetRunDurationModelList () const; 00080 // Contains models which are expected to last for the duration of 00081 // the run, for example geometry volumes. 00082 00083 const std::vector<Model>& GetEndOfEventModelList () const; 00084 // Contains models which are described at the end of event when the 00085 // scene is current. 00086 00087 const std::vector<Model>& GetEndOfRunModelList () const; 00088 // Contains models which are described at the end of event when the 00089 // scene is current. 00090 00091 const G4VisExtent& GetExtent () const; 00092 // Overall extent of all objects in the scene. 00093 00094 const G4Point3D& GetStandardTargetPoint () const; 00095 // Usually centre of extent. See G4ViewParameters for definition. 00096 00097 G4bool GetRefreshAtEndOfEvent () const; 00098 // If true, the visualization manager will request viewer to refresh 00099 // "transient" objects, such as hits, at end of event. Otherwise 00100 // they will be accumulated. 00101 00102 G4int GetMaxNumberOfKeptEvents() const; 00103 // If RefreshAtEndOfEvent is false, events of the current run are 00104 // kept up to this maximum number. A negative value means all 00105 // events of current run are kept. The events are available for 00106 // viewing at the end of run, but are deleted just before the start 00107 // of the next run. 00108 00109 G4bool GetRefreshAtEndOfRun () const; 00110 // If true, the visualization manager will request viewer to refresh 00111 // "transient" objects, such as hits, at end of run. Otherwise 00112 // they will be accumulated. 00113 00115 // Add and Set functions... 00116 00117 G4bool AddRunDurationModel (G4VModel*, G4bool warn = false); 00118 // Adds models of type which are expected to last for the duration 00119 // of the run, for example geometry volumes. 00120 // Returns false if model is already in the list. 00121 // Prints warnings if warn is true. 00122 00123 G4bool AddWorldIfEmpty (G4bool warn = false); 00124 // In some situations, if the user asks for a drawing and has not 00125 // yet set any run duration models it makes sense to put the "world" 00126 // in there by default. 00127 // Returns false if model is already in the list. 00128 // Prints warnings if warn is true. 00129 00130 G4bool AddEndOfEventModel (G4VModel*, G4bool warn = false); 00131 // Adds models of type which are described at the end of event when 00132 // the scene is current. 00133 // Returns false if model is already in the list. 00134 // Prints warnings if warn is true. 00135 00136 G4bool AddEndOfRunModel (G4VModel*, G4bool warn = false); 00137 // Adds models of type which are described at the end of run when 00138 // the scene is current. 00139 // Returns false if model is already in the list. 00140 // Prints warnings if warn is true. 00141 00142 void SetName (const G4String&); 00143 // Use with care. User normally sets scene name by vis commands. 00144 00145 std::vector<Model>& SetRunDurationModelList (); 00146 // Allows you to change the model list - do with care! 00147 00148 std::vector<Model>& SetEndOfEventModelList (); 00149 // Allows you to change the model list - do with care! 00150 00151 std::vector<Model>& SetEndOfRunModelList (); 00152 // Allows you to change the model list - do with care! 00153 00154 void SetRefreshAtEndOfEvent(G4bool); 00155 // If set true, the visualization manager will request viewer to 00156 // refresh "transient" objects, such as hits, at end of event. 00157 // Otherwise they will be accumulated. 00158 00159 void SetMaxNumberOfKeptEvents(G4int); 00160 // If RefreshAtEndOfEvent is false, events of the current run are 00161 // kept up to this maximum number. A negative value means all 00162 // events of current run are kept. The events are available for 00163 // viewing at the end of run, but are deleted just before the start 00164 // of the next run. 00165 00166 void SetRefreshAtEndOfRun(G4bool); 00167 // If set true, the visualization manager will request viewer to 00168 // refresh "transient" objects, such as hits, at end of run. 00169 // Otherwise they will be accumulated. 00170 00172 // Other functions... 00173 00174 void CalculateExtent(); 00175 // (Re-)calculates the extent from the extents of its models. 00176 00177 private: 00178 G4String fName; 00179 std::vector<Model> fRunDurationModelList; 00180 std::vector<Model> fEndOfEventModelList; 00181 std::vector<Model> fEndOfRunModelList; 00182 G4VisExtent fExtent; 00183 G4Point3D fStandardTargetPoint; 00184 G4bool fRefreshAtEndOfEvent; 00185 G4bool fRefreshAtEndOfRun; 00186 G4int fMaxNumberOfKeptEvents; 00187 }; 00188 00189 #include "G4Scene.icc" 00190 00191 #endif