source: trunk/geant4/visualization/management/include/G4VSceneHandler.hh@ 557

Last change on this file since 557 was 531, checked in by garnier, 18 years ago

r660@mac-90108: laurentgarnier | 2007-06-25 16:10:12 +0200
ajout de fichiers NON modifies

  • Property svn:mime-type set to text/cpp
File size: 14.5 KB
Line 
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: G4VSceneHandler.hh,v 1.37 2006/11/15 19:25:31 allison Exp $
28// GEANT4 tag $Name: geant4-08-02-patch-01 $
29//
30//
31// John Allison 19th July 1996.
32//
33// Class description
34//
35// Abstract interface class for graphics scene handlers.
36// Inherits from G4VGraphicsScene, in the intercoms category, which is
37// a minimal abstract interface for the GEANT4 kernel.
38
39#ifndef G4VSCENEHANDLER_HH
40#define G4VSCENEHANDLER_HH
41
42#include "globals.hh"
43
44#include <stack>
45
46#include "G4VGraphicsScene.hh"
47#include "G4ViewerList.hh"
48#include "G4ViewParameters.hh"
49
50class G4Scene;
51class G4VViewer;
52class G4Colour;
53class G4Visible;
54class G4ModelingParameters;
55class G4VModel;
56class G4VGraphicsSystem;
57class G4LogicalVolume;
58class G4VPhysicalVolume;
59class G4Material;
60class G4Event;
61
62class G4VSceneHandler: public G4VGraphicsScene {
63
64public: // With description
65
66 friend std::ostream& operator << (std::ostream& os, const G4VSceneHandler& s);
67
68 enum MarkerSizeType {world, screen};
69
70 G4VSceneHandler (G4VGraphicsSystem& system,
71 G4int id,
72 const G4String& name = "");
73
74 virtual ~G4VSceneHandler ();
75
76 ///////////////////////////////////////////////////////////////////
77 // Methods for adding raw GEANT4 objects to the scene handler. They
78 // must always be called in the triplet PreAddSolid, AddSolid and
79 // PostAddSolid. The transformation and visualization attributes
80 // must be set by the call to PreAddSolid. If your graphics system
81 // is sophisticated enough to handle a particular solid shape as a
82 // primitive, in your derived class write a function to override one
83 // or more of the following. See the implementation of
84 // G4VSceneHandler::AddSolid (const G4Box& box) for more
85 // suggestions. If not, please implement the base class invocation.
86
87 virtual void PreAddSolid (const G4Transform3D& objectTransformation,
88 const G4VisAttributes& visAttribs);
89 // objectTransformation is the transformation in the world
90 // coordinate system of the object about to be added, and visAttribs
91 // is its visualization attributes.
92 // IMPORTANT: invoke this from your polymorphic versions, e.g.:
93 // void MyXXXSceneHandler::PreAddSolid
94 // (const G4Transform3D& objectTransformation,
95 // const G4VisAttributes& visAttribs) {
96 // G4VSceneHandler::PreAddSolid (objectTransformation, visAttribs);
97 // ...
98 // }
99
100 virtual void PostAddSolid ();
101 // IMPORTANT: invoke this from your polymorphic versions, e.g.:
102 // void MyXXXSceneHandler::PostAddSolid () {
103 // ...
104 // G4VSceneHandler::PostAddSolid ();
105 // }
106
107 virtual void AddSolid (const G4Box&);
108 virtual void AddSolid (const G4Cons&);
109 virtual void AddSolid (const G4Tubs&);
110 virtual void AddSolid (const G4Trd&);
111 virtual void AddSolid (const G4Trap&);
112 virtual void AddSolid (const G4Sphere&);
113 virtual void AddSolid (const G4Para&);
114 virtual void AddSolid (const G4Torus&);
115 virtual void AddSolid (const G4Polycone&);
116 virtual void AddSolid (const G4Polyhedra&);
117 virtual void AddSolid (const G4VSolid&); // For solids not above.
118
119 ///////////////////////////////////////////////////////////////////
120 // Methods for adding "compound" GEANT4 objects to the scene
121 // handler. These methods may either (a) invoke "user code" that
122 // uses the "user interface", G4VVisManager (see, for example,
123 // G4VSceneHandler, which for trajectories uses
124 // G4VTrajectory::DrawTrajectory, via G4TrajectoriesModel in the
125 // Modeling Category) or (b) invoke AddPrimitives below (between
126 // calls to Begin/EndPrimitives) or (c) use graphics-system-specific
127 // code or (d) any combination of the above.
128
129 virtual void AddCompound (const G4VTrajectory&);
130 virtual void AddCompound (const G4VHit&);
131
132 //////////////////////////////////////////////////////////////
133 // Functions for adding primitives.
134
135 virtual void BeginModeling ();
136 // IMPORTANT: invoke this from your polymorphic versions, e.g.:
137 // void MyXXXSceneHandler::BeginModeling () {
138 // G4VSceneHandler::BeginModeling ();
139 // ...
140 // }
141
142 virtual void EndModeling ();
143 // IMPORTANT: invoke this from your polymorphic versions, e.g.:
144 // void MyXXXSceneHandler::EndModeling () {
145 // ...
146 // G4VSceneHandler::EndModeling ();
147 // }
148
149 virtual void BeginPrimitives
150 (const G4Transform3D& objectTransformation);
151 // IMPORTANT: invoke this from your polymorphic versions, e.g.:
152 // void MyXXXSceneHandler::BeginPrimitives
153 // (const G4Transform3D& objectTransformation) {
154 // G4VSceneHandler::BeginPrimitives (objectTransformation);
155 // ...
156 // }
157
158 virtual void EndPrimitives ();
159 // IMPORTANT: invoke this from your polymorphic versions, e.g.:
160 // void MyXXXSceneHandler::EndPrimitives () {
161 // ...
162 // G4VSceneHandler::EndPrimitives ();
163 // }
164
165 virtual void BeginPrimitives2D ();
166 // The x,y coordinates of the primitives passed to AddPrimitive are
167 // intrepreted as screen coordinates, -1 < x,y < 1. The
168 // z-coordinate is ignored.
169 // IMPORTANT: invoke this from your polymorphic versions, e.g.:
170 // void MyXXXSceneHandler::BeginPrimitives2D
171 // (const G4Transform3D& objectTransformation) {
172 // G4VSceneHandler::BeginPrimitives2D ();
173 // ...
174 // }
175
176 virtual void EndPrimitives2D ();
177 // IMPORTANT: invoke this from your polymorphic versions, e.g.:
178 // void MyXXXSceneHandler::EndPrimitives2D () {
179 // ...
180 // G4VSceneHandler::EndPrimitives2D ();
181 // }
182
183 virtual void AddPrimitive (const G4Polyline&) = 0;
184 virtual void AddPrimitive (const G4Scale&);
185 // Default implementation in this class but can be over-ridden.
186 virtual void AddPrimitive (const G4Text&) = 0;
187 virtual void AddPrimitive (const G4Circle&) = 0;
188 virtual void AddPrimitive (const G4Square&) = 0;
189 virtual void AddPrimitive (const G4Polymarker&);
190 // Default implementation in this class but can be over-ridden.
191 virtual void AddPrimitive (const G4Polyhedron&) = 0;
192 virtual void AddPrimitive (const G4NURBS&) = 0;
193
194 //////////////////////////////////////////////////////////////
195 // Access functions.
196 const G4String& GetName () const;
197 G4int GetSceneHandlerId () const;
198 G4int GetViewCount () const;
199 G4VGraphicsSystem* GetGraphicsSystem () const;
200 G4Scene* GetScene () const;
201 const G4ViewerList& GetViewerList () const;
202 G4VModel* GetModel () const;
203 G4VViewer* GetCurrentViewer () const;
204 G4bool GetMarkForClearingTransientStore () const;
205 G4bool IsReadyForTransients () const;
206 G4bool GetTransientsDrawnThisEvent () const;
207 G4bool GetTransientsDrawnThisRun () const;
208 void SetName (const G4String&);
209 void SetCurrentViewer (G4VViewer*);
210 void SetScene (G4Scene*);
211 G4ViewerList& SetViewerList (); // Non-const so you can change.
212 void SetModel (G4VModel*);
213 void SetMarkForClearingTransientStore (G4bool);
214 // Sets flag which will cause transient store to be cleared at the
215 // next call to BeginPrimitives(). Maintained by vis manager.
216 void SetTransientsDrawnThisEvent (G4bool);
217 void SetTransientsDrawnThisRun (G4bool);
218 // Maintained by vis manager.
219 void SetEvent (const G4Event*);
220 // If non-zero, this event is used in ProcessScene. Otherwise, the
221 // current event, or last event(s) are used. The user must
222 // SetEvent(0) when finished.
223
224 //////////////////////////////////////////////////////////////
225 // Public utility functions.
226
227 const G4Colour& GetColour (const G4Visible&);
228 const G4Colour& GetColor (const G4Visible&);
229 // Returns colour of G4Visible object, or default global colour.
230
231 const G4Colour& GetTextColour (const G4Text&);
232 const G4Colour& GetTextColor (const G4Text&);
233 // Returns colour of G4Text object, or default text colour.
234
235 G4double GetLineWidth(const G4Visible& visible);
236 // Returns line width of G4Visible object, or default line width.
237 // Multiplies by GlobalLineWidthScale.
238
239 G4ViewParameters::DrawingStyle GetDrawingStyle (const G4VisAttributes*);
240 // Returns drawing style from current view parameters, unless the user
241 // has forced through the vis attributes, thereby over-riding the
242 // current view parameter.
243
244 G4bool GetAuxEdgeVisible (const G4VisAttributes*);
245 // Returns auxiliary edge visibility from current view parameters,
246 // unless the user has forced through the vis attributes, thereby
247 // over-riding the current view parameter.
248
249 G4int GetNoOfSides(const G4VisAttributes* pVisAttribs);
250 // Returns no. of sides (lines segments per circle) from current
251 // view parameters, unless the user has forced through the vis
252 // attributes, thereby over-riding the current view parameter.
253
254 G4double GetMarkerSize (const G4VMarker&, MarkerSizeType&);
255 // Returns applicable marker size (diameter) and type (in second
256 // argument). Uses global default marker if marker sizes are not
257 // set. Multiplies by GlobalMarkerScale.
258
259 G4double GetMarkerDiameter (const G4VMarker&, MarkerSizeType&);
260 // Alias for GetMarkerSize.
261
262 G4double GetMarkerRadius (const G4VMarker&, MarkerSizeType&);
263 // GetMarkerSize / 2.
264
265 G4ModelingParameters* CreateModelingParameters ();
266 // Only the scene handler and view know what the Modeling Parameters should
267 // be. For historical reasons, the GEANT4 Visualization Environment
268 // maintains its own Scene Data and View Parameters, which must be
269 // converted, when needed, to Modeling Parameters.
270
271 void DrawEvent(const G4Event*);
272 // Checks scene's end-of-event model list and draws trajectories,
273 // hits, etc.
274
275 //////////////////////////////////////////////////////////////
276 // Administration functions.
277
278 G4int IncrementViewCount ();
279
280 virtual void ClearStore ();
281 // Clears graphics database (display lists) if any. This base class
282 // implements some common functionality so...
283 // IMPORTANT: invoke this from your polymorphic versions, e.g.:
284 // void MyXXXSceneHandler::ClearStore () {
285 // G4VSceneHandler::ClearStore ();
286 // ...
287 // }
288
289 virtual void ClearTransientStore ();
290 // Clears transient part of graphics database (display lists) if any.
291 // This base class implements some common functionality so...
292 // IMPORTANT: invoke this from your polymorphic versions, e.g.:
293 // void MyXXXSceneHandler::ClearTransientStore () {
294 // G4VSceneHandler::ClearTransientStore ();
295 // ...
296 // }
297
298 void AddViewerToList (G4VViewer* pView); // Add view to view List.
299 void RemoveViewerFromList (G4VViewer* pView); // Remove view from view List.
300
301protected:
302
303 //////////////////////////////////////////////////////////////
304 // Default routine used by default AddSolid ().
305
306 virtual void RequestPrimitives (const G4VSolid& solid);
307
308 //////////////////////////////////////////////////////////////
309 // Other internal routines...
310
311 virtual const G4Polyhedron* CreateSectionPolyhedron ();
312 virtual const G4Polyhedron* CreateCutawayPolyhedron ();
313 // Generic clipping using the BooleanProcessor in graphics_reps is
314 // implemented in this class. Subclasses that implement their own
315 // clipping should provide an override that returns zero.
316
317 //////////////////////////////////////////////////////////////
318 // Data members
319
320 G4VGraphicsSystem& fSystem; // Graphics system.
321 const G4int fSceneHandlerId; // Id of this instance.
322 G4String fName;
323 G4int fViewCount; // To determine view ids.
324 G4ViewerList fViewerList; // Viewers.
325 G4VViewer* fpViewer; // Current viewer.
326 G4Scene* fpScene; // Scene for this scene handler.
327 G4bool fMarkForClearingTransientStore;
328 G4bool fReadyForTransients; // I.e., not processing the
329 // run-duration part of scene.
330 G4bool fTransientsDrawnThisEvent; // Maintained by vis
331 G4bool fTransientsDrawnThisRun; // manager.
332 G4bool fProcessingSolid; // True if within Pre/PostAddSolid.
333 G4bool fSecondPassRequested;
334 G4bool fSecondPass; // ...in process.
335 G4VModel* fpModel; // Current model.
336 const G4Transform3D* fpObjectTransformation; // Current accumulated
337 // object transformation.
338 G4int fNestingDepth; // For Begin/EndPrimitives.
339 const G4VisAttributes* fpVisAttribs; // Working vis attributes.
340 const G4Event* fRequestedEvent; // If non-zero, use this event.
341 const G4Transform3D fIdentityTransformation;
342
343private:
344
345 G4VSceneHandler (const G4VSceneHandler&);
346 G4VSceneHandler& operator = (const G4VSceneHandler&);
347
348 //////////////////////////////////////////////////////////////
349 // Friend function accessed only by views of this scene.
350
351 friend void G4VViewer::ProcessView ();
352
353 //////////////////////////////////////////////////////////////
354 // Private functions, etc..
355
356 void ProcessScene (G4VViewer& view);
357 // Accessed by G4VViewer::ProcessView ().
358
359};
360
361#include "G4VSceneHandler.icc"
362
363#endif
Note: See TracBrowser for help on using the repository browser.