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10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/management/include/G4VViewer.hh (Version 11.3.0) and /visualization/management/include/G4VViewer.hh (Version 1.1)


                                                   >>   1 // This code implementation is the intellectual property of
                                                   >>   2 // the GEANT4 collaboration.
  1 //                                                  3 //
  2 // ******************************************* <<   4 // By copying, distributing or modifying the Program (or any work
  3 // * License and Disclaimer                    <<   5 // based on the Program) you indicate your acceptance of this statement,
  4 // *                                           <<   6 // and all its terms.
  5 // * The  Geant4 software  is  copyright of th << 
  6 // * the Geant4 Collaboration.  It is provided << 
  7 // * conditions of the Geant4 Software License << 
  8 // * LICENSE and available at  http://cern.ch/ << 
  9 // * include a list of copyright holders.      << 
 10 // *                                           << 
 11 // * Neither the authors of this software syst << 
 12 // * institutes,nor the agencies providing fin << 
 13 // * work  make  any representation or  warran << 
 14 // * regarding  this  software system or assum << 
 15 // * use.  Please see the license in the file  << 
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                           << 
 18 // * This  code  implementation is the result  << 
 19 // * technical work of the GEANT4 collaboratio << 
 20 // * By using,  copying,  modifying or  distri << 
 21 // * any work based  on the software)  you  ag << 
 22 // * use  in  resulting  scientific  publicati << 
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // ******************************************* << 
 25 //                                             << 
 26 //                                                  7 //
                                                   >>   8 // $Id: G4VViewer.hh,v 1.5 1999/12/15 14:54:19 gunter Exp $
                                                   >>   9 // GEANT4 tag $Name: geant4-01-01 $
 27 //                                                 10 //
 28 //                                                 11 // 
 29 // John Allison  27th March 1996                   12 // John Allison  27th March 1996
 30 //                                                 13 //
 31 // Class description                               14 // Class description
 32 //                                                 15 //
 33 // Abstract interface class for graphics viewe     16 // Abstract interface class for graphics viewers.
 34                                                    17 
 35 #ifndef G4VVIEWER_HH                               18 #ifndef G4VVIEWER_HH
 36 #define G4VVIEWER_HH                               19 #define G4VVIEWER_HH
 37                                                    20 
 38 #include "globals.hh"                              21 #include "globals.hh"
 39                                                    22 
 40 #include "G4SceneTreeItem.hh"                  << 
 41                                                << 
 42 #include "G4ViewParameters.hh"                     23 #include "G4ViewParameters.hh"
 43 #include "G4PhysicalVolumeModel.hh"            << 
 44 #include "G4PseudoScene.hh"                    << 
 45                                                << 
 46 #include <vector>                              << 
 47 #include <list>                                << 
 48                                                    24 
 49 class G4VSceneHandler;                             25 class G4VSceneHandler;
 50                                                    26 
 51 // clang-format off                            << 
 52 class G4VViewer {                                  27 class G4VViewer {
 53                                                    28 
 54 public: // With description                        29 public: // With description
 55                                                    30 
 56   friend std::ostream& operator << (std::ostre <<  31   friend G4std::ostream& operator << (G4std::ostream& os, const G4VViewer& v);
 57                                                    32 
 58   G4VViewer (G4VSceneHandler&, G4int id, const <<  33   G4VViewer (G4VSceneHandler& scene, G4int id, const G4String& name = "");
 59   virtual ~G4VViewer ();                           34   virtual ~G4VViewer ();
 60                                                    35 
 61   virtual void Initialise ();                  <<  36   // For G4RWTPtrOrderedVector...
 62   // Called immediately after construction for <<  37   G4bool operator == (const G4VViewer& view) const;
 63   // must await complete contruction of viewer << 
 64   // example, if this class (G4VViewer) is inh << 
 65   // the OpenGL sub-category, it will not be f << 
 66   // *after* the the derived viewer (this is t << 
 67   // construction for virtual inheritance), so << 
 68   // not use information in G4VViewer in its c << 
 69   // code must be in Initialise().             << 
 70                                                    38 
 71   ////////////////////////////////////////////     39   //////////////////////////////////////////////////////////////
 72   // View manipulation functions.                  40   // View manipulation functions.
 73                                                    41 
 74   virtual void ResetView ();                   << 
 75   // Reset view parameters to default, includi << 
 76   // The sub-class should always invoke the ba << 
 77   // virtual void SubClass::ResetView () {     << 
 78   //   G4VViewer::ResetView();                 << 
 79   //   // Then reset sub-class parameters      << 
 80   //   ...                                     << 
 81                                                << 
 82   virtual void SetView () = 0;                     42   virtual void SetView () = 0;
 83   // Take view parameters and work out model/v     43   // Take view parameters and work out model/view transformation,
 84   // projection transformation, lighting, etc.     44   // projection transformation, lighting, etc.
 85                                                    45 
 86   virtual void ClearView () = 0;                   46   virtual void ClearView () = 0;
 87   // Clear screen/viewing buffers.                 47   // Clear screen/viewing buffers.
 88                                                    48 
 89   virtual void DrawView () = 0;                    49   virtual void DrawView () = 0;
 90   // Draw view of the scene currently attached <<  50   // Draw scene - see example of a minimal function at end of this file.
 91   // see example of a minimal function at end  << 
 92                                                << 
 93   void RefreshView ();                         << 
 94   // Simply invokes SetView, ClearView, DrawVi << 
 95                                                    51 
 96   virtual void ShowView ();                        52   virtual void ShowView ();
 97   // Show view (for graphics systems which req     53   // Show view (for graphics systems which require to process
 98   // all drawn objects before finalising the v     54   // all drawn objects before finalising the view).
 99                                                    55 
100   virtual void FinishView ();                      56   virtual void FinishView ();
101   // Called at the end of drawing scene.  Used     57   // Called at the end of drawing scene.  Used to flush streams, or
102   // swap buffers.  (Perhaps it is inappropria     58   // swap buffers.  (Perhaps it is inappropriately named, perhaps its
103   // function could be incorporated into EndMo     59   // function could be incorporated into EndModeling ().  It marks the
104   // end of scene drawing; be aware hits and d     60   // end of scene drawing; be aware hits and digi drawing may Follow.
105   // It is not yet the end of all drawing; tha     61   // It is not yet the end of all drawing; that is signalled by
106   // ShowView ().)                                 62   // ShowView ().)
107                                                    63 
108   virtual G4bool ReadyToDraw() {return true;}  << 
109                                                << 
110   std::vector<G4ThreeVector> ComputeFlyThrough << 
111                                                << 
112   // Note: the order of calling of MovingToVis << 
113   // is undefined, so you may need to implemen << 
114   // order - see, e.g., G4OpenGLQtViewer. To s << 
115   // as follows - see G4VisManager.cc.         << 
116   // DoneWithMasterThread                      << 
117   // MovingToVisSubThread ) or ( SwitchToVisSu << 
118   // SwitchToVisSubThread )    ( MovingToVisSu << 
119   // DoneWithVisSubThread                      << 
120   // MovingToMasterThread                      << 
121   // SwitchToMasterThread                      << 
122                                                << 
123   // Called on the master thread before starti << 
124   virtual void DoneWithMasterThread () {}      << 
125                                                << 
126   // Called on the master thread after startin << 
127   virtual void MovingToVisSubThread () {}      << 
128                                                << 
129   // Called on the vis sub-thread at start of  << 
130   virtual void SwitchToVisSubThread () {}      << 
131                                                << 
132   // Called on the vis sub-thread when all eve << 
133   virtual void DoneWithVisSubThread () {}      << 
134                                                << 
135   // Called on the vis sub-thread when all eve << 
136   virtual void MovingToMasterThread () {}      << 
137                                                << 
138   // Called on the master thread after the vis << 
139   virtual void SwitchToMasterThread () {}      << 
140                                                << 
141   //////////////////////////////////////////// << 
142   // Stuff for scene tree.                     << 
143   /**                                          << 
144    - The scene tree is a tree of G4SceneTreeIt << 
145    - Its root is a data member fSceneTree of a << 
146    G4VViewer inheritance,                      << 
147    - G4SceneTreeItem is an aggregate of data m << 
148    properties of objects in the scene (G4Scene << 
149    low-level types - G4String, G4VisAttributes << 
150    that it can be used across categories, avoi << 
151    - The root item has children that represent << 
152    sub-classes) in the scene.                  << 
153    - For a G4PhysicalVolumeModel (detector com << 
154    children's children, etc., imitate the geom << 
155    model. These descendants are called "toucha << 
156    - There may be more than one G4PhysicalVolu << 
157    the user creates his/her scene.             << 
158    - The scene tree is reviewed, and updated i << 
159    of G4VSceneHandler::ProcessScene.  This is  << 
160    - A kernel visit is triggered by some vis c << 
161    /vis/viewer/rebuild) and by a viewer if it  << 
162    example, a kernel visit may not be required << 
163    but required for a change from surface to w << 
164    - The idea is that the scene tree can be pa << 
165    create a tree widget, and interactions with << 
166    /vis/scene/activateModel, /vis/set/touchabl << 
167    The viewer decides if this requires a kerne << 
168    must update fSceneTree itself (utilities ar << 
169    G4VViewer::TouchableSetVisibility/Colour).  << 
170   */                                           << 
171   class SceneTreeScene: public G4PseudoScene { << 
172     // G4PhysicalVolumeModel sends touchables  << 
173   public:                                      << 
174     SceneTreeScene(G4VViewer*, G4PhysicalVolum << 
175     ~SceneTreeScene() = default;               << 
176   private:                                     << 
177     void ProcessVolume(const G4VSolid& solid)  << 
178     std::list<G4SceneTreeItem>::iterator FindO << 
179     (const G4String& modelID, G4SceneTreeItem& << 
180      G4int depth, const G4String& partialPathS << 
181     G4VViewer* fpViewer = nullptr;             << 
182     G4PhysicalVolumeModel* fpPVModel = nullptr << 
183     std::list<G4SceneTreeItem>::iterator  fMod << 
184     G4int fMaximumExpandedDepth = 0;    // To  << 
185     const G4int fMaximumExpanded = 30;  // So  << 
186   };                                           << 
187   void InsertModelInSceneTree(G4VModel*);      << 
188   const G4SceneTreeItem& GetSceneTree() {retur << 
189   G4SceneTreeItem& AccessSceneTree() {return f << 
190   void UpdateGUISceneTree();  // A utility     << 
191   const G4int fMaxNTouchables = 10000;  // Lim << 
192   G4bool fCurtailDescent = false;  // Flag to  << 
193                                                << 
194   ////////////////////////////////////////////     64   //////////////////////////////////////////////////////////////
195   // Access functions.                             65   // Access functions.
196   const G4String&         GetName           ()     66   const G4String&         GetName           () const;
197   const G4String&         GetShortName      () << 
198   void                    SetName           (c     67   void                    SetName           (const G4String&);
199   G4int                   GetViewId         ()     68   G4int                   GetViewId         () const;
200   G4VSceneHandler*        GetSceneHandler   () <<  69         G4VSceneHandler*         GetScene          () const;
201   const G4ViewParameters& GetViewParameters    <<  70   const G4ViewParameters& GetViewParameters () const;
202   const G4ViewParameters& GetDefaultViewParame <<  71   void SetViewParameters  (const G4ViewParameters& vp);
203   G4double                GetKernelVisitElapse << 
204                                                << 
205   virtual const std::vector<G4ModelingParamete << 
206   GetPrivateVisAttributesModifiers() const;    << 
207   // So that privately accumulated vis attribu << 
208   // concatenated with the standard vis attrib << 
209   // such as /vis/viewer/set/all and /vis/view << 
210                                                << 
211   void SetViewParameters         (const G4View << 
212   void SetDefaultViewParameters  (const G4View << 
213                                                    72 
214   ////////////////////////////////////////////     73   //////////////////////////////////////////////////////////////
215   // Public utility functions.                     74   // Public utility functions.
216                                                    75 
217   const G4VisAttributes*  GetApplicableVisAttr     76   const G4VisAttributes*  GetApplicableVisAttributes
218                                             (c     77                                             (const G4VisAttributes*) const;
219                                                    78 
220   void SetNeedKernelVisit (G4bool need);       <<  79   void SetNeedKernelVisit ();
221   // Sets individual need-visit flag.          <<  80   // Sets individual need-visit flags.
222                                                    81 
223   void NeedKernelVisit ();                         82   void NeedKernelVisit ();
224   // Flags all views the need to re-visit the      83   // Flags all views the need to re-visit the GEANT4 kernel to refresh
225   // the scene.                                    84   // the scene.
226                                                    85 
227   void ProcessView ();                         << 
228   // Used by DrawView ().  Invokes SetView (). << 
229                                                << 
230 protected:                                         86 protected:
231                                                    87 
232   //////////////////////////////////////////// <<  88   void ProcessView ();
233   // Protected utility functions.              <<  89   // Used by DrawView ().  Invokes SetView ().  The basic logic is here.
234                                                << 
235   void SetTouchable                            << 
236   (const std::vector<G4PhysicalVolumeModel::G4 << 
237   // Set the touchable for /vis/touchable/set/ << 
238                                                << 
239   void TouchableSetVisibility                  << 
240   (const std::vector<G4PhysicalVolumeModel::G4 << 
241    G4bool visibility);                         << 
242   // Set the touchable visibility attribute.   << 
243   // Changes the Vis Attribute Modifiers WITHO << 
244                                                << 
245   void TouchableSetColour                      << 
246   (const std::vector<G4PhysicalVolumeModel::G4 << 
247    const G4Colour&);                           << 
248   // Set the touchable colour attribute.       << 
249   // Changes the Vis Attribute Modifiers WITHO << 
250                                                    90 
251   ////////////////////////////////////////////     91   //////////////////////////////////////////////////////////////
252   // Data members                                  92   // Data members
253   G4VSceneHandler&        fSceneHandler;     /     93   G4VSceneHandler&        fSceneHandler;     // Abstract scene for this view.
254   G4int            fViewId;    // Id of this i     94   G4int            fViewId;    // Id of this instance.
255   G4String         fName;                          95   G4String         fName;
256   G4String         fShortName; // Up to first  <<  96   G4ViewParameters fVP;        // Viewing parameters.
257   G4ViewParameters fVP;        // View paramet << 
258   G4ViewParameters fDefaultVP; // Default view << 
259   G4double         fKernelVisitElapsedTimeSeco << 
260   // Note: fKernelVisitElapsedTimeSeconds is m << 
261   G4SceneTreeItem  fSceneTree;                 << 
262                                                    97 
263   ////////////////////////////////////////////     98   //////////////////////////////////////////////////////////////
264   // Other parameters.                             99   // Other parameters.
                                                   >> 100   G4bool           fModified;         // If View Parameters have been modified.
265   G4bool           fNeedKernelVisit;  // See D    101   G4bool           fNeedKernelVisit;  // See DrawView() for comments.
266 };                                                102 };
267                                                   103 
268 #include "G4VViewer.icc"                          104 #include "G4VViewer.icc"
269                                                   105 
270 /*********************************************    106 /*********************************************
271                                                   107 
272 Here is a minimal DrawView () as it might be i    108 Here is a minimal DrawView () as it might be implemented in the
273 concrete viewer.                               << 109 concrete view.
274                                                   110 
275 void G4VViewer::DrawView () {  // Default - co    111 void G4VViewer::DrawView () {  // Default - concrete view usually overrides.
276                                                   112 
277   // First, a view should decide when to re-vi    113   // First, a view should decide when to re-visit the G4 kernel.
278   // Sometimes it might not be necessary, e.g.    114   // Sometimes it might not be necessary, e.g., if the scene is stored
279   // in a graphical database (e.g., OpenGL's d    115   // in a graphical database (e.g., OpenGL's display lists) and only
280   // the viewing angle has changed.  But graph    116   // the viewing angle has changed.  But graphics systems without a
281   // graphical database will always need to vi    117   // graphical database will always need to visit the G4 kernel.
282                                                   118 
283   NeedKernelVisit ();  // Default is - always     119   NeedKernelVisit ();  // Default is - always visit G4 kernel.
284   // Note: this routine sets the fNeedKernelVi    120   // Note: this routine sets the fNeedKernelVisit flag of *all* the views of
285   // the scene.                                   121   // the scene.
286                                                   122 
287   ProcessView ();             // The basic log    123   ProcessView ();             // The basic logic is here.
288                                                   124 
289   // Then a view may have more to do, e.g., di    125   // Then a view may have more to do, e.g., display the graphical
290   // database.  That code should come here bef    126   // database.  That code should come here before finally...
291                                                   127 
292   FinishView ();              // Flush streams    128   FinishView ();              // Flush streams and/or swap buffers.
293 }                                                 129 }
294                                                   130 
295 *********************************************/    131 *********************************************/
296                                                   132 
297 #endif                                            133 #endif
298                                                   134