Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4VViewer.cc
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//
29//
30// John Allison 27th March 1996
31// Abstract interface class for graphics views.
32
33#include "G4VViewer.hh"
34
35#include "G4ios.hh"
36#include <sstream>
37
38#include "G4VisManager.hh"
39#include "G4VGraphicsSystem.hh"
40#include "G4VSceneHandler.hh"
41#include "G4Scene.hh"
42#include "G4VPhysicalVolume.hh"
43#include "G4Transform3D.hh"
44
46 G4int id, const G4String& name):
47fSceneHandler (sceneHandler),
48fViewId (id),
49//fModified (true),
50fNeedKernelVisit (true)
51{
52 if (name == "") {
53 std::ostringstream ost;
54 ost << fSceneHandler.GetName () << '-' << fViewId;
55 fName = ost.str();
56 }
57 else {
58 fName = name;
59 }
60 fShortName = fName (0, fName.find (' '));
62
63 fVP = G4VisManager::GetInstance()->GetDefaultViewParameters();
65}
66
69}
70
71void G4VViewer::SetName (const G4String& name) {
72 fName = name;
73 fShortName = fName (0, fName.find (' '));
75}
76
78(const G4VisAttributes* pVisAttribs) const {
79 // If pVisAttribs is zero, pick up the default vis attributes from
80 // the view parameters.
81 if (!pVisAttribs)
83 return pVisAttribs;
84}
85
87
88 fNeedKernelVisit = true;
89
90 // At one time I thought we'd better notify all viewers. But I guess
91 // each viewer can take care of itself, so the following code is
92 // redundant (but keep it commented out for now). (John Allison)
93 // Notify all viewers that a kernel visit is required.
94 // const G4ViewerList& viewerList = fSceneHandler.GetViewerList ();
95 // G4ViewerListConstIterator i;
96 // for (i = viewerList.begin(); i != viewerList.end(); i++) {
97 // (*i) -> SetNeedKernelVisit ();
98 // }
99 // ??...but, there's a problem in OpenGL Stored which seems to
100 // require *all* viewers to revisit the kernel, so...
101 /*
102 const G4ViewerList& viewerList = fSceneHandler.GetViewerList ();
103 G4ViewerListConstIterator i;
104 for (i = viewerList.begin(); i != viewerList.end(); i++) {
105 (*i) -> SetNeedKernelVisit (true);
106 }
107 */
108 // Feb 2005 - commented out. Let's fix OpenGL if necessary.
109}
110
112
114
116{
117 // If the scene has changed, or if the concrete viewer has decided
118 // that it necessary to visit the kernel, perhaps because the view
119 // parameters have changed significantly (this should be done in the
120 // concrete viewer's DrawView)...
121 if (fNeedKernelVisit) {
122 // Reset flag. This must be done before ProcessScene to prevent
123 // recursive calls when recomputing transients...
124 fNeedKernelVisit = false;
127 }
128}
129
131 fVP = vp;
132}
133
134std::ostream& operator << (std::ostream& os, const G4VViewer& v) {
135 os << "View " << v.fName << ":\n";
136 os << v.fVP;
137 return os;
138}
int G4int
Definition: G4Types.hh:66
std::ostream & operator<<(std::ostream &os, const G4VViewer &v)
Definition: G4VViewer.cc:134
G4String strip(G4int strip_Type=trailing, char c=' ')
virtual void ProcessScene()
const G4String & GetName() const
void RemoveViewerFromList(G4VViewer *pView)
virtual void ClearStore()
G4bool fNeedKernelVisit
Definition: G4VViewer.hh:142
const G4VisAttributes * GetApplicableVisAttributes(const G4VisAttributes *) const
Definition: G4VViewer.cc:78
void SetName(const G4String &)
Definition: G4VViewer.cc:71
const G4ViewParameters & GetViewParameters() const
void ProcessView()
Definition: G4VViewer.cc:115
G4VSceneHandler & fSceneHandler
Definition: G4VViewer.hh:133
G4String fShortName
Definition: G4VViewer.hh:136
virtual ~G4VViewer()
Definition: G4VViewer.cc:67
G4String fName
Definition: G4VViewer.hh:135
void NeedKernelVisit()
Definition: G4VViewer.cc:86
G4ViewParameters fDefaultVP
Definition: G4VViewer.hh:138
G4int fViewId
Definition: G4VViewer.hh:134
G4ViewParameters fVP
Definition: G4VViewer.hh:137
virtual void FinishView()
Definition: G4VViewer.cc:111
G4VViewer(G4VSceneHandler &, G4int id, const G4String &name="")
Definition: G4VViewer.cc:45
void SetViewParameters(const G4ViewParameters &vp)
Definition: G4VViewer.cc:130
virtual void ShowView()
Definition: G4VViewer.cc:113
const G4VisAttributes * GetDefaultVisAttributes() const
const G4ViewParameters & GetDefaultViewParameters() const