source: trunk/source/visualization/management/src/G4VViewer.cc@ 894

Last change on this file since 894 was 894, checked in by garnier, 17 years ago

only debug msg

  • Property svn:mime-type set to text/cpp
File size: 5.1 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.24 2007/01/05 16:25:15 allison Exp $
28// GEANT4 tag $Name: HEAD $
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#ifdef G4DEBUG
69 printf("G4VViewer::G4VViewer set geometry of viewer\n");
70#endif
71 fVP.SetWindowSizeHint(xHint,yHint);
72 fVP.SetXGeometryString(XGeometryString);
73 fDefaultVP.SetWindowSizeHint(xHint,yHint);
74 fDefaultVP.SetXGeometryString(XGeometryString);
75}
76
77G4VViewer::~G4VViewer () {}
78
79void G4VViewer::SetName (const G4String& name) {
80 fName = name;
81 fShortName = fName (0, fName.find (' '));
82 fShortName.strip ();
83}
84
85const G4VisAttributes* G4VViewer::GetApplicableVisAttributes
86(const G4VisAttributes* pVisAttribs) const {
87 // If pVisAttribs is zero, pick up the default vis attributes from
88 // the view parameters.
89 if (!pVisAttribs)
90 pVisAttribs = GetViewParameters ().GetDefaultVisAttributes ();
91 return pVisAttribs;
92}
93
94void G4VViewer::NeedKernelVisit () {
95
96 fNeedKernelVisit = true;
97
98 // At one time I thought we'd better notify all viewers. But I guess
99 // each viewer can take care of itself, so the following code is
100 // redundant (but keep it commented out for now). (John Allison)
101 // Notify all viewers that a kernel visit is required.
102 // const G4ViewerList& viewerList = fSceneHandler.GetViewerList ();
103 // G4ViewerListConstIterator i;
104 // for (i = viewerList.begin(); i != viewerList.end(); i++) {
105 // (*i) -> SetNeedKernelVisit ();
106 // }
107 // ??...but, there's a problem in OpenGL Stored which seems to
108 // require *all* viewers to revisit the kernel, so...
109 /*
110 const G4ViewerList& viewerList = fSceneHandler.GetViewerList ();
111 G4ViewerListConstIterator i;
112 for (i = viewerList.begin(); i != viewerList.end(); i++) {
113 (*i) -> SetNeedKernelVisit (true);
114 }
115 */
116 // Feb 2005 - commented out. Let's fix OpenGL if necessary.
117}
118
119void G4VViewer::FinishView () {}
120
121void G4VViewer::ShowView () {}
122
123void G4VViewer::ProcessView ()
124{
125 // If ClearStore has been requested, e.g., if the scene has changed,
126 // or if the concrete viewer has decided that it necessary to visit
127 // the kernel, perhaps because the view parameters have changed
128 // significantly (this should be done in the concrete viewer's
129 // DrawView)...
130 if (fNeedKernelVisit) {
131 // Reset flag. This must be done before ProcessScene to prevent
132 // recursive calls when recomputing transients...
133 fNeedKernelVisit = false;
134 fSceneHandler.ProcessScene (*this);
135 }
136}
137
138void G4VViewer::SetViewParameters (const G4ViewParameters& vp) {
139 fVP = vp;
140}
141
142std::ostream& operator << (std::ostream& os, const G4VViewer& v) {
143 os << "View " << v.fName << ":\n";
144 os << v.fVP;
145 return os;
146}
Note: See TracBrowser for help on using the repository browser.