Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VVisManager.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$
28 // John Allison 19/Oct/1996.
29 //
30 // Class Description:
31 //
32 // G4VVisManager is an abstract interface for the GEANT4 Visualization Manager.
33 // The inheritance hierarchy is:
34 // G4VVisManager <- G4VisManager <- G4VisExecutive
35 //
36 // You may also write your own vis manager in place of G4VisExecutive.
37 //
38 // See example/novice/N02 to see how and when to instantiate
39 // G4VisExecutive (or your own vis manager). You should *not* access
40 // it directly; instead you should obtain a pointer as follows:
41 //
42 // G4VVisManager* pVVMan = G4VVisManager::GetConcreteInstance ();
43 //
44 // This ensures your code will link even if G4VisExecutive is not
45 // instantiated or even if not provided in a library. Please protect
46 // your code by testing the pointer, for example, by:
47 //
48 // if (pVVMan) pVVMan -> Draw (polyline);
49 //
50 // The Draw functions draw only "transient" objects. This is useful
51 // for debugging, e.g., drawing the step in your UserSteppingAction,
52 // since G4Steps are not kept.
53 //
54 // Note: "permanent" objects, i.e., objects which are always
55 // available, such as detector geometry components, or available in an
56 // event after tracking has finished, such as hits, digitisations and
57 // trajectories, can be drawn in a transient way if you wish but it is
58 // usually possible to draw them in a permanent way with /vis/
59 // commands. The advantage is that permanent objects can be redrawn,
60 // e.g., when you change view or viewer; transient objects get
61 // forgotten. Also, it is possible to write a G4VUserVisAction class
62 // and register it to "promote" your Draw messages to "permanent" -
63 // see documentation.
64 //
65 // Note that the G4Transform3D argument refers to the transformation
66 // of the *object*, not the transformation of the coordinate syste.
67 //
68 // Note also that where a G4VisAttributes argument is specified, it
69 // overrides any attributes belonging to the object itself.
70 
71 #ifndef G4VVISMANAGER_HH
72 #define G4VVISMANAGER_HH
73 
74 #include "G4Transform3D.hh"
75 #include "G4ThreeVector.hh" // Just a typedef Hep3Vector.
76 #include "G4RotationMatrix.hh" // Just a typedef HepRotation.
77 
78 class G4Polyline;
79 class G4Text;
80 class G4Circle;
81 class G4Scale;
82 class G4Square;
83 class G4Polymarker;
84 class G4Polyhedron;
85 class G4NURBS;
86 class G4VSolid;
87 class G4VHit;
88 class G4VDigi;
89 class G4VTrajectory;
90 class G4LogicalVolume;
91 class G4VPhysicalVolume;
92 class G4VisAttributes;
93 
95 
96 public: // With description
97 
99  // Returns pointer to actual visualization manager if a view is
100  // available for drawing, else returns null. Always check value.
101 
102 public:
103 
104  virtual ~G4VVisManager ();
105 
106 public: // With description
107 
109  // Draw methods for Geant4 Visualization Primitives, useful
110  // for representing hits, digis, etc.
111 
112  virtual void Draw (const G4Circle&,
113  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
114 
115  virtual void Draw (const G4NURBS&,
116  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
117 
118  virtual void Draw (const G4Polyhedron&,
119  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
120 
121  virtual void Draw (const G4Polyline&,
122  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
123 
124  virtual void Draw (const G4Polymarker&,
125  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
126 
127  virtual void Draw (const G4Scale&,
128  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
129 
130  virtual void Draw (const G4Square&,
131  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
132 
133  virtual void Draw (const G4Text&,
134  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
135 
137  // For 2D methods, the x,y coordinates are interpreted as screen
138  // coordinates, -1 < x,y < 1. The z-coordinate is ignored.
139 
140  virtual void Draw2D (const G4Circle&,
141  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
142 
143  virtual void Draw2D (const G4NURBS&,
144  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
145 
146  virtual void Draw2D (const G4Polyhedron&,
147  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
148 
149  virtual void Draw2D (const G4Polyline&,
150  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
151 
152  virtual void Draw2D (const G4Polymarker&,
153  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
154 
155  virtual void Draw2D (const G4Square&,
156  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
157 
158  virtual void Draw2D (const G4Text&,
159  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
160 
162  // Draw methods for Geant4 Objects as if they were Visualization
163  // Primitives. Note that the visualization attributes needed in
164  // some cases override any visualization attributes that are
165  // associated with the object itself - thus you can, for example,
166  // change the colour of a physical volume.
167 
168  virtual void Draw (const G4VHit&) = 0;
169 
170  virtual void Draw (const G4VDigi&) = 0;
171 
172  virtual void Draw (const G4VTrajectory&, G4int i_mode = 0) = 0;
173  // i_mode is a parameter that can be used to control the drawing of
174  // the trajectory. See, e.g., G4TrajectoryDrawByCharge::Draw in the
175  // modeling sub-category. Its use is deprecated; use trajectory
176  // model commands instead.
177 
178  virtual void Draw (const G4LogicalVolume&, const G4VisAttributes&,
179  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
180 
181  virtual void Draw (const G4VPhysicalVolume&, const G4VisAttributes&,
182  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
183 
184  virtual void Draw (const G4VSolid&, const G4VisAttributes&,
185  const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
186 
188  // Optional methods that you may use to bracket a series of Draw
189  // messages that have identical objectTransformation to improve
190  // drawing speed. Use Begin/EndDraw for a series of Draw messages,
191  // Begin/EndDraw2D for a series of Draw2D messages. Do not mix Draw
192  // and Draw2D messages.
193 
194  virtual void BeginDraw
195  (const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
196 
197  virtual void EndDraw () = 0;
198 
199  virtual void BeginDraw2D
200  (const G4Transform3D& objectTransformation = G4Transform3D()) = 0;
201 
202  virtual void EndDraw2D () = 0;
203 
205  // Other methods...
206 
207  virtual void GeometryHasChanged () = 0;
208  // This is used by the run manager to notify a change of geometry.
209 
210  virtual void NotifyHandlers () {}
211  // Notify scene handlers (G4VGraphicsScene objects) that the scene
212  // has changed so that they may rebuild their graphics database, if
213  // any, and redraw all views.
214 
215  virtual void DispatchToModel(const G4VTrajectory&) = 0;
216  virtual void DispatchToModel(const G4VTrajectory&, G4int i_mode) = 0;
217  // Draw the trajectory.
218 
219  virtual G4bool FilterTrajectory(const G4VTrajectory&) = 0;
220  // Trajectory filter
221 
222  virtual G4bool FilterHit(const G4VHit&) = 0;
223  // Hit filter
224 
225  virtual G4bool FilterDigi(const G4VDigi&) = 0;
226  // Digi filter
227 
228 protected:
229 
230  static void SetConcreteInstance (G4VVisManager*);
231 
232  static G4VVisManager* fpConcreteInstance; // Pointer to real G4VisManager.
233 };
234 
235 #endif