source: trunk/geant4/visualization/management/src/G4VViewer.cc@ 552

Last change on this file since 552 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: 5.0 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: G4VViewer.cc,v 1.23 2006/06/29 21:29:26 gunter Exp $
28// GEANT4 tag $Name: geant4-08-01-patch-01 $
29//
30//
31// John Allison 27th March 1996
32// Abstract interface class for graphics views.
33
34#include "G4VViewer.hh"
35
36#include "G4ios.hh"
37#include <sstream>
38
39#include "G4VisManager.hh"
40#include "G4VGraphicsSystem.hh"
41#include "G4VSceneHandler.hh"
42#include "G4Scene.hh"
43#include "G4VPhysicalVolume.hh"
44#include "G4Transform3D.hh"
45
46G4VViewer::G4VViewer (G4VSceneHandler& sceneHandler,
47 G4int id, const G4String& name):
48fSceneHandler (sceneHandler),
49fViewId (id),
50//fModified (true),
51fNeedKernelVisit (true)
52{
53 if (name == "") {
54 std::ostringstream ost;
55 ost << fSceneHandler.GetName () << '-' << fViewId;
56 fName = ost.str();
57 }
58 else {
59 fName = name;
60 }
61 fShortName = fName (0, fName.find (' '));
62 fShortName.strip ();
63
64 G4VisManager* pVisMan = G4VisManager::GetInstance();
65 G4int xHint, yHint;
66 pVisMan->GetWindowSizeHint(xHint, yHint);
67 const G4String& XGeometryString = pVisMan->GetXGeometryString();
68 fVP.SetWindowSizeHint(xHint,yHint);
69 fVP.SetXGeometryString(XGeometryString);
70 fDefaultVP.SetWindowSizeHint(xHint,yHint);
71 fDefaultVP.SetXGeometryString(XGeometryString);
72}
73
74G4VViewer::~G4VViewer () {}
75
76void G4VViewer::SetName (const G4String& name) {
77 fName = name;
78 fShortName = fName (0, fName.find (' '));
79 fShortName.strip ();
80}
81
82const G4VisAttributes* G4VViewer::GetApplicableVisAttributes
83(const G4VisAttributes* pVisAttribs) const {
84 // If the pointer is null, pick up the default vis attributes from
85 // the view parameters.
86 if (!pVisAttribs)
87 pVisAttribs = GetViewParameters ().GetDefaultVisAttributes ();
88 return pVisAttribs;
89}
90
91void G4VViewer::NeedKernelVisit () {
92
93 fNeedKernelVisit = true;
94
95 // At one time I thought we'd better notify all viewers. But I guess
96 // each viewer can take care of itself, so the following code is
97 // redundant (but keep it commented out for now). (John Allison)
98 // Notify all viewers that a kernel visit is required.
99 // const G4ViewerList& viewerList = fSceneHandler.GetViewerList ();
100 // G4ViewerListConstIterator i;
101 // for (i = viewerList.begin(); i != viewerList.end(); i++) {
102 // (*i) -> SetNeedKernelVisit ();
103 // }
104 // ??...but, there's a problem in OpenGL Stored which seems to
105 // require *all* viewers to revisit the kernel, so...
106 /*
107 const G4ViewerList& viewerList = fSceneHandler.GetViewerList ();
108 G4ViewerListConstIterator i;
109 for (i = viewerList.begin(); i != viewerList.end(); i++) {
110 (*i) -> SetNeedKernelVisit (true);
111 }
112 */
113 // Feb 2005 - commented out. Let's fix OpenGL if necessary.
114}
115
116void G4VViewer::FinishView () {}
117
118void G4VViewer::ShowView () {}
119
120void G4VViewer::ProcessView ()
121{
122 // If ClearStore has been requested, e.g., if the scene has changed,
123 // or if the concrete viewer has decided that it necessary to visit
124 // the kernel, perhaps because the view parameters have changed
125 // significantly (this should be done in the concrete viewer's
126 // DrawView)...
127 if (fNeedKernelVisit) {
128 // Reset flag. This must be done before ProcessScene to prevent
129 // recursive calls when recomputing transients...
130 fNeedKernelVisit = false;
131 fSceneHandler.ProcessScene (*this);
132 }
133}
134
135void G4VViewer::SetViewParameters (const G4ViewParameters& vp) {
136 fVP = vp;
137}
138
139std::ostream& operator << (std::ostream& os, const G4VViewer& v) {
140 os << "View " << v.fName << ":\n";
141 os << v.fVP;
142 return os;
143}
Note: See TracBrowser for help on using the repository browser.